Author Topic: cannot find -luser32 etc.  (Read 1376 times)

Offline typicalc

  • Multiple posting newcomer
  • *
  • Posts: 22
cannot find -luser32 etc.
« on: January 30, 2025, 12:13:25 pm »
When I compile a WIN32 C project I don't get any warnings or errors but at the end of linking I get:
ld.exe||cannot find -lgdi32|
ld.exe||cannot find -luser32|
ld.exe||cannot find -lkernel32|
ld.exe||cannot find -lcomctl32|
ld.exe||cannot find -lstdc++|
..etc.
If I create a new Win32 C  default program it compiles and links just fine. So the libraries should be available.

If I take the C files from the problematic project and add it to the normally compiling and linking project and start getting the "cannot find" linking errors.
I have added in "Project buil option" Linker setting" "link libraries" lines
gdi32
user32
..
etc.
What can I do?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1673
Re: cannot find -luser32 etc.
« Reply #1 on: January 30, 2025, 01:16:20 pm »
If you are using MinGW then you must add libgdi32.a, libuser32.a and so on.

Order of the linked libraries does matter, this libraries should go at the end of the list.

Offline typicalc

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: cannot find -luser32 etc.
« Reply #2 on: January 30, 2025, 03:14:57 pm »
How do I add them?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1673
Re: cannot find -luser32 etc.
« Reply #3 on: January 30, 2025, 06:10:02 pm »
How do I add them?

Just like you did previously:

Quote
I have added in "Project buil option" Linker setting" "link libraries" lines

Offline typicalc

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: cannot find -luser32 etc.
« Reply #4 on: January 31, 2025, 03:48:50 pm »
Ok I found what the problem was. When I check on "Target x86 (32bit) [-m32]" I get the problems.
I seems that I do not have the 32bit libraries. How do I install them back? Or would it be easier to re-install Code::Blocks?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1673
Re: cannot find -luser32 etc.
« Reply #5 on: January 31, 2025, 04:22:43 pm »
Those libraries come with the compiler, probably your version of MinGW only generates 64-bit code so it does not incllude de 32-bit libraries.

Offline typicalc

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: cannot find -luser32 etc.
« Reply #6 on: January 31, 2025, 05:19:06 pm »
How would I setup Code::blocks to be able to compile and link 32-bit win32 executables? What do I need to download & install and from where?