Jump to content
  • Advertisement
Sign in to follow this  

Setting up GLFW for MinGW CodeBlocks

This topic is 2096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well... I'm kinda new to this stuff... but can somebody help me figure out how to setup GLFW for CodeBlocks for Windows.... I have installed MinGW version of CodeBlocks... i tried to follow the release notes given in their sites, but i just don't get it... They have given how to compile using MinGW... Can anyone explain me the line (taken from the release notes of GLFW) which is given below:


GLFW can be compiled using only MinGW. Open a Windows command prompt, enter the root directory of the GLFW source distribution and use the win32-mingw target:

mingw32-make win32-mingw


Share this post

Link to post
Share on other sites

If you have MinGW installed, have it configured so that the MinGW/bin directory is part of the PATH, then you can open a Windows Command Prompt window, navigate to the root directory of wherever you unzipped the GLFW source, and type mingw32-make win32-mingw and it should build the library.


mingw32-make is the MinGW version of make. Make is a command-line tool (hence the need to open a command prompt window) that, when executed, will look for a file called Makefile in the executing directory. Makefile contains instructions for make, telling it how to build the project. A Makefile can specify certain targets to build, allowing the library maintainer to provide different build paths for different build environments. The win32-mingw target mentioned above, then, would instruct it to build the MinGW-specific path. Other build environments such as Linux would need to specify a different build target.


If all is set up correctly, executing the above instruction will result in a build. You should see a bunch of text spam in the command prompt window as files are compiled and libraries are linked. GLFW isn't huge, so it shouldn't take too long. If there are any errors, you'll need to note the error messages and try to figure out what went wrong. If it says that mingw32-make.exe is not a valid program, then you need to set up your PATH.


The PATH, of course, is the system environment variable telling Windows where to look when commands are executed at the command prompt. Go into your Control Panel, search for environment variables, and edit your system PATH, appending the path to your MinGW/bin directory. You'll probably have to restart your computer for the new PATH to be in effect.


Other errors might occur if there are missing dependencies in the project. I believe that GLFW includes any third-party dependencies, so you shouldn't have any problems there.


Once all is done, you will end up with some library files, usually a file called something like libGLFW.a if it is a static build, or a .DLL if it is shared. These libraries may be found somewhere in the build tree; commonly, a folder called lib but sometimes just dumped in the same folder as the source files. Link this library with your application to use GLFW.

Share this post

Link to post
Share on other sites

When building with Code::Blocks/MinGW, I usually just import the Visual Studio solution provided. It works most of the time and you don't have to cut through the command line jungle.

Share this post

Link to post
Share on other sites

Alright I figured it out...

To "anyone who had no idea how to sort out this stuff and reached here", you gotta do this for setting up GLFW:

1. Download the MinGW version of CodeBlocks and install it.
2. Download MinGW from is official site amd install in this directory:
3. Download GLFW from its official site [http://www.glfw.org/].
4. After downloading it extract it, lets say in Desktop...
5. Right click My Computer and select Properties.
6. Go to "Advanced System Settings".
7. In the box that appears, click "Environment Variables...".
8. In the box named "System Variables", search for "Path" or "PATH" under "Variable" column.
9. Double click it and then a box will appear.
10. In the "Variable" box, you will see directories of some installed stuff... Over here, you have to give your MinGW directory...
Type this: ";C:\MinGW\bin" (excluding quotes).
NOTE: Adding semicolon is mandatory as it separates from other directories given in that box.
Click OK, OK, and OK.
11. Open command prompt... Then type the following command:
C:\Users\yourcomputername> cd <the directory where you extracted GLFW>
For example, mine was like this:
C:\Users\PB9X> cd desktop\glfw-2.7.7
12. After you have typed that command, type the following command:
mingw32-make win32-mingw
Mine was like this:
C:\Users\PB9X\Desktop\glfw-2.7.7> mingw32-make win32-mingw
13. After typing that command, the compilation will take place.
14. After the compiling is over, go to the place where you have extracted glfw, and in that folder, you'll find a sub folder named "lib". In "lib" folder, open the folder named
15. Over here copy these files: libglfw.a, glfw.dll and libglfwdll.a to C:\Program Files (x86)\CodeBlocks\MinGW\lib
16. Copy glfw.dll to the system folder where opengl32.dll is located. It should be in C:\Windows\System32 (for 32 bit Windows) or C:\Windows\SysWOW64 (for 64 bit Windows). If opengl32.dll is located in both the directories, then do it for both of them. For me it was in both directories. So I copied to both of them. It won't create any problem.
17. Copy glfw.h from the "include" subfolder in the glfw folder you have extracted and paste it to C:\Program Files (x86)\CodeBlocks\MinGW\include\GL

Now the CodeBlocks part:

1. Open a new GLFW project and name the prject whatever you want and give the directory where you want to save your project. Then click Next.
2. Then it will ask you to select GLFW's location. Give this directory : C:\Program Files (x86)\Codeblocks\MinGW. Click Next and then click Finish.
3. In the "Management" area (it should be in the left side), collapse the folder named "Sources" and open main.cpp and run it.
4. Enjoy.... And start writing your GLFW programs... smile.png

Edited by parthibbiswas93

Share this post

Link to post
Share on other sites

Good of you to document it in detail, for future googling from others.


[quote name='parthibbiswas93' timestamp='1356616080' post='5014689']
15. Over here copy these files: libglfw.a, glfw.dll and libglfwdll.a to C:\Program Files (x86)\CodeBlocks\MinGW\lib

Notice that libglfw.a is for statically linked libraries, and libglfwdll.a is for dynamcally linked.


If you distribute your application someday, you will need to include glfw.dll if you use dynamical linkage. I used static linkage of glfw, to make it easier for me.


Microsoft strongly recommends using dynamic linkage. The performance cost is negligible, and the idea is that dll:s can be updated separately. However, with a library compiled by you, it is probably never going to be updated separately.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!