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

h4tt3n wrote on Thursday, December 19, 2013:

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

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

tshez wrote on Saturday, December 21, 2013:

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

dougbinks wrote on Saturday, December 21, 2013:

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

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:

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

h4tt3n wrote on Monday, December 23, 2013:

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

dougbinks wrote on Monday, December 23, 2013:

Glad you got it working!

Merry xmas to you too :slight_smile: