GLFW in Code::Blocks

How do I make GLFW works in code::blocks?

Keep getting “undefined reference to `glfwInit’” and nothing I found online helps.
I Linked the libraries like it says in the C::B site and write the #includes like it says in the GLFW site, but I still get that error.

-------------- Clean: Debug in Trying (compiler: GNU GCC Compiler)---------------

Cleaned "Trying - Debug"

-------------- Build: Debug in Trying (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -Iinclude -c "K:\Trying\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -Llib -o bin\Debug\Trying.exe obj\Debug\main.o   lib\libglfw3.a lib\libgdi32.a lib\libopengl32.a
obj\Debug\main.o: In function `main':
K:/Trying/main.cpp:10: undefined reference to `glfwInit'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

The error you’re getting is a link error. It’s likely that the GLFW library you have is the wrong one - where did you get your library from?

Note that an alternative is building from source, this post covers how for Code::Blocks.

Also do note that both MinGW and Code Blocks are not the easiest approach to use for Windows development, you might find using cmake and Visual Studio Community edition (which is free) easier.

Thanks for replying.
I was using the lib-mingw-w64 I got from the site BECAUSE…
I followed the steps to build it from source, like it says in the link you posted (which are the same steps I found in other sites), but it doesn’t works.
When I hit “Configure” and set “CodeBlocks MinGW makefiles”, CMake complains about printf not being found in libintl-8.dll many times and says project files may be invalid. It also shows “CMAKE_CODEBLOCKS_EXECUTABLE-NOTFOUND” in the upper side and “The C compiler identification is unknown” in the lower side.

I did reinstalled Code::Blocks(with MinGW) and CMake many times and still didn’t works.

From your build output it looks like you are using the 32bit version of MinGW. Thus you need to use the 32bit libraries. Download the 32-bit Windows Binaries for GLFW here. You’ll find the 32bit MinGW binaries in the lib-mingw folder.

im also having problems with codeblocks because now the header file is being named glfw3.h rather than just glfw.h what can i do to resolve this please dont suggest visual studio :frowning:

Have you tried changing #include <GLFW/glfw.h> to #include <GLFW/glfw3.h> ?