Mingw64 on windows option -lglfw3 does absolutely nothing

as the title says, linking glfw3 statically using -lglfw3 does nothing. on the other side, adding the libglfw3.a as an object to be linked works perfectly fine.

it happens for both precompiled binaries, and binaries compiled on my system.
i’m on a windows 10 x86_64 box, using the mingw chocolatey build (gcc version 12.2.0 (x86_64-posix-seh-rev2, Built by MinGW-W64 project)) with the target x86_64-w64-mingw32.


gcc -lglfw3

doesn’t work, but

gcc libglfw3.a

works just fine


edit: for clarification, by doing nothing i mean it does not link the symbols, as they get reported as undefined references.

Try to add -L. argument to specify folder where gcc looks for library files.

i tried to be as short as possible, so i didn’t include details, but of course i did that, otherwise the compiler won’t find it at all and i wouldn’t be here in the first place.

the linker (i’m using gcc for linking) only complains about undefined references that are defined in libglfw3.a.

Can you please show exact command line you are running? And exact error message you are getting?

i’ll be home in about 6-7 hours, when i’m going to make a minimal example.

but the explanation is pretty on point. i even explained in layman’s terms.
i am very sure that i’m not missing anything obvious.

i feel the need to mention that the build environment links other libraries just fine.

nevermind, i realised that i made a very obvious mistake and that is adding the object files after the library.

what i did:

gcc -Lpath/to/library -lglfw3 -lopengl32 -letc... main.o

what i should have done:

gcc -Lpath/to/library main.o -lglfw3 -lopengl32 -letc...