Unable to statically link to GLFW lib, but no problems dynamically, why?

I'm using GLFW for creating a gl context in C++. Would anybody know why when using GCC and mingw-w64, I'm unable to statically link to their lib, and instead I must link dynamically?

I'll add a link below with the solution that worked for me, but unfortunately the poster has no idea why the solution works, but I do want to know.

https://m.reddit.com/r/learnprogramming/comments/1gdr16/mingw_glfw_3_undefined_references_when_linking/

Read icdae's answer. Again, my program compiles perfectly, but I'd like to learn what's why static linking doesn't work.

Oh and this is how I compile my program just in case, ignore Vulkan.

 
g++ src/main.cpp src/renderer.cpp src/debug.cpp src/time.cpp -I include -I include -L lib -lglfw3dll -lvulkan-1 -o Game


More Detail:

Also, I downloaded the proper zip from the GLFW site that includes a folder named "lib-mingw-w64", which has: glfw3.dll, libglfw3.a, libglfw3dll.a and is what I'm using right now.

Thanks!
Last edited on
What do you mean by "unable"? When you link statically you also have to link its dependencies.
.
Last edited on
@LB actually you can ignore the answer above, I did a little more research on the difference between static and dynamic linking and I believe I understand what you mean now. If I statically link, I must include any required dependencies, in my case opengl32.

I read a lot of people suggesting dynamic linking more since less code is copied.
There are advantages and disadvantages to both dynamic and static linking - it really depends on your use case. For a game, it doesn't really matter so much, so just do whatever's easier for now.
Topic archived. No new replies allowed.