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

Offline typicalc

  • Multiple posting newcomer
  • *
  • Posts: 23
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: 1706
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: 23
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: 1706
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: 23
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: 1706
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: 23
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?

Offline reckless

  • Regular
  • ***
  • Posts: 353
Re: cannot find -luser32 etc.
« Reply #7 on: March 15, 2025, 09:08:03 am »
you can use allmost whatever compiler you like borland msvc mingw watcom etc.
the thing to look out for is if you are not familar with the compiler you chose to use as they all use different flags for the same operation.

for msys2 you can download the codeblocks package via pacman but if you want to use the 32 bit mingw compiler you need to do a bit of compiler setup since it defaults to 64 bit mingw.

borland atleast the older free version defaults to 32 bit so should be easy enough.
msvc has it's own ide so using codeblocks with it is more user preference.
watcom also comes with an ide but it lacks quite a few features like syntax highlighting.
TDM-mingw has both 32 and 64 bit mingw compilers (in one package even) and was shipped with older versions of codeblocks.
the problem with TDM is that it was discontinued somewhere around gcc 10 so it lacks some of the more modern standards.
it was also a bit buggy at times.

as for where to get them use google or startpage or whatever search engine you fancy.
« Last Edit: March 15, 2025, 09:14:27 am by reckless »