Jump to content

  • Log In with Google      Sign In   
  • Create Account


Setting up GLFW for MinGW CodeBlocks


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 parthibbiswas93   Members   -  Reputation: 160

Like
0Likes
Like

Posted 25 December 2012 - 12:18 PM

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

 



Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8409

Like
1Likes
Like

Posted 25 December 2012 - 03:29 PM

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.



#3 ifthen   Members   -  Reputation: 820

Like
0Likes
Like

Posted 26 December 2012 - 03:14 AM

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.



#4 parthibbiswas93   Members   -  Reputation: 160

Like
0Likes
Like

Posted 27 December 2012 - 07:48 AM

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:
C:\MinGW
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
"win32".
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, 27 December 2012 - 08:10 AM.


#5 larspensjo   Members   -  Reputation: 1526

Like
0Likes
Like

Posted 28 December 2012 - 03:45 PM

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

 

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.


Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS