Issues with installing pre-compiled GLFW libraries with code blocks


#1

I’ve recently taken an interest in OpenGL rendering, but I can’t for the life of me seem to get the GLFW libraries to work. I’ve followed instructions on installing the pre-compiled libraries from videos such as

https://www.youtube.com/watch?v=0WrSGMuU964 and https://www.youtube.com/watch?v=CBNoa3ZxUq4

down to a tee, and spent countless hours scrutinizing over the details and trying to understand the happenings of compilers and linkers, but alas, I couldn’t fix my problem, so here I am seeking help. What am I doing wrong?

I downloaded the 32-bit windows binaries.
I moved the “include” and “lib-mingw” folders into my project’s folder (Console Application).
Under “Project > Build Options > Search Directories > Compiler” I added the “include” directory as a relative path.
Under “Project > Build Options > Search Directories > Linker” I added the “lib-mingw” directory as a relative path.
Under “Project > Build Options > Linker Settings” I added “glfw3”, “gdi32” and “opengl32” to the Link Libraries

Then when I try compiling the project with the sample code from the GLFW documentation, I receive the errors:
cannot find -lglfw3
Id returned 1 exit status

I find this more confusing yet, since there isn’t a “gdi32” nor “opengl32” in the “lib-mingw” folder, and there IS a glfw3 library file in it, yet that is the one it doesn’t manage to find. I’ve tried adding only the glfw3 library file in the lib-mingw folder to the “Link-Libraries” as a non-relative path, but that didn’t work either. Any ideas what I’ve done wrong here?

Thank you greatly in advance.
~ Jeremy


#2

gdi32/opengl32 libraries come with mingw, so that’s why you don’t need them in glfw downloaded archive.

Can you see output of linker command in CodeBlocks? Does it have “-Lpath/to/lib-mingw” argument same as you set it?


#3

After taking a look at the build log, it seems it’s skipping over all of the libglfw.a files because it thinks they’re incompatible?
https://pastebin.com/fVA4EkLW

And if I enter the direct path to the libglfw.a file non-relatively, it just doesn’t manage to read it.
https://pastebin.com/7kY4UzLV


#4

You are using a compiler that produces 64-bit binaries (x86_64-w64-mingw32-g++.exe) so you need to use 64-bit GLFW library files. These are in lib-mingw-w64 in the 64-bit binary archive.


#5

Ohh! I’ll test it out. Thank you!


#6

What would the new linked libraries be for the 64-bit binaries instead of gdi32 and opengl32? I would have assumed gdi64 and opengl64, but apparently, they can’t be found.

gdi32 and opengl32 seem to be found, but I still get a bunch of errors:
https://pastebin.com/u6SxFmYq

Build Log:
https://pastebin.com/MqSCwMCk


#7

I finally got it! glfw3 had to be linked before gdi32 and opengl3. Thanks for your help guys!


#8

Confusingly enough, the 64-bit versions of gdi32 and opengl32 don’t have different names. It’s similar to why Windows’ System32 folder contains 64-bit libraries, and SysWoW64 contains 32-bit…


#9

Hmm, That’s true. I haven’t thought of it like that before.