# GLFW in Code::Blocks

**URL:** <https://discourse.glfw.org/t/glfw-in-code-blocks/975>\
**Category:** support\
**Created:** [August 22, 2017, 6:39am UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975 "2017-08-22T06:39:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![UndefinedReference](https://avatars.discourse-cdn.com/v4/letter/u/df788c/32.png) [@UndefinedReference](https://discourse.glfw.org/u/UndefinedReference)\
**Post date:** [August 22, 2017, 6:39am UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975/1 "2017-08-22T06:39:02Z")

</div>

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))
```

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [August 22, 2017, 9:19am UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975/2 "2017-08-22T09:19:01Z")

</div>

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](http://discourse.glfw.org/t/static-build-on-codeblocks-with-mingw/63/3).

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.

---

<div class="post-metadata">

**Author:** ![UndefinedReference](https://avatars.discourse-cdn.com/v4/letter/u/df788c/32.png) [@UndefinedReference](https://discourse.glfw.org/u/UndefinedReference)\
**Post date:** [August 22, 2017, 10:12am UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975/3 "2017-08-22T10:12:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [August 22, 2017, 10:56am UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975/4 "2017-08-22T10:56:02Z")

</div>

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](https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN32.zip). You’ll find the 32bit MinGW binaries in the lib-mingw folder.

---

<div class="post-metadata">

**Author:** ![gtx](https://avatars.discourse-cdn.com/v4/letter/g/ad7895/32.png) [@gtx](https://discourse.glfw.org/u/gtx)\
**Post date:** [August 17, 2019, 11:09pm UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975/5 "2019-08-17T23:09:52Z")

</div>

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 ☹

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [August 18, 2019, 2:04am UTC](https://discourse.glfw.org/t/glfw-in-code-blocks/975/6 "2019-08-18T02:04:25Z")

</div>

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