# How to set up GLFW3 in Code::Blocks (windows)?

**URL:** <https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27>\
**Category:** support\
**Created:** [December 19, 2013, 3:37pm UTC](https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27 "2013-12-19T15:37:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [December 19, 2013, 3:37pm UTC](https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27/1 "2013-12-19T15:37:43Z")

</div>

**[h4tt3n](https://sourceforge.net/u/h4tt3n/)** wrote on [Thursday, December 19, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/d10a4eed/#9f8a):

Hello folks,

Could someone here kindly explain how to set up the new GLFW3 in the Code::Blocks environment? I have used earlier versions of both glfw and code blocks for years, and it baffles me that I simply cannot make this setup work despite hours of tinkering.

I’m using the pre-built code blocks 12.11 mingw setup version available here:

[http://www.codeblocks.org/downloads/26](http://www.codeblocks.org/downloads/26)

I’m running a fresh Windows 7 install. I have placed the two include files in

CodeBlocks/MinGW/include/GLFW

and the two lib files in

CodeBlocks/MinGW/lib.

The dll file is placed in Windows/System32 folder.

I have tried a large number of different linker settings.

When trying to run the short example code in the GLFW documentation page ( [http://www.glfw.org/documentation.html](http://www.glfw.org/documentation.html) ), I get a lot of “undefined reference to…” errors.

I have tried everything I can think of, including a complete re-install of codeblocks, switching between the 32 and 64 bit version of glfw3, linking to static and/or dynamic lib version, all without having a clue what’s wrong.

If you’re running glfw3 won’t you please just write down how you installed the damn thing?

Cheers,  
Mike

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [December 21, 2013, 9:10am UTC](https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27/2 "2013-12-21T09:10:55Z")

</div>

**[tshez](https://sourceforge.net/u/tshez/)** wrote on [Saturday, December 21, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/d10a4eed/#1659):

I too am having this issue…using Visual Studio 2010.

For example, when I try to call glfwInit(); I get the following compiling error:  
“error LNK2019: unresolved external symbol \_glfwInit”.

However if i call glfwInit(); like this:  
int glfwInit(); (with the int before glfwInit()) it will compile without errors.

I’ve tried just about everything. Using the lib files in mingw and msvc110 files. Tried it with dll’s in the .exe folder as well as system32 folder and I’ve tripled checked my linker.

Any help would be greatly appreciated  
Thanks in advance for your time,  
Tim

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [December 21, 2013, 10:48am UTC](https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27/3 "2013-12-21T10:48:56Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Saturday, December 21, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/d10a4eed/#4750):

Build issues are difficult to diagnose without the output, and there are two different issues here (Codeblocks and Visual studio).

@Tim - It might help to move your question to a new thread if the help posted here doesn’t solve your problem. Note that the line “int glfwInit();” declares a new function which returns int, thus compiling but not doing anything.

@Mike - I’m not a CodeBlocks expert, and installing / configuring that would take more time than I have to offer atm. Hopefully the stuff here helps, if not more information such as the actual log output may be required. It doesn’t sound as if you used cmake to create the project files, which means that you’ll need to manually configure glfw - possible but a potentially lengthy process. The status of the Codeblocks cmake generators seems a little immature, so if you simply want to get up and running quickly the Visual Studio Express Desktop C++ compilers are free and easy to use with GLFW on Windows.

General building issues covered here: [http://www.glfw.org/docs/latest/build.html](http://www.glfw.org/docs/latest/build.html)

Note the part about dlls in the section “With MinGW or Visual C++ on Windows” if you want to use dlls. You’ll need to define GLFW\_DLL before including glfw as here:

```auto
#define GLFW_DLL
#include <GL/glfw.h>

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [December 23, 2013, 3:14pm UTC](https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27/4 "2013-12-23T15:14:56Z")

</div>

**[h4tt3n](https://sourceforge.net/u/h4tt3n/)** wrote on [Monday, December 23, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/d10a4eed/#ed07):

Okay, got it working. Now I can compile 32-bit glfw programs, haven’t tested 64-bit yet.  
Once I’ve tested things more thoroughly I’ll post a detailed description for future reference. Thank you everyone for your contributions.

Cheers & merry christmas,  
MIke

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [December 23, 2013, 4:44pm UTC](https://discourse.glfw.org/t/how-to-set-up-glfw3-in-code-blocks-windows/27/5 "2013-12-23T16:44:03Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Monday, December 23, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/d10a4eed/#2811):

Glad you got it working!

Merry xmas to you too 🙂
