Lazy Foo' Productions


Setting up freeGLUT on Code::Blocks 10.05

Setting up freeGLUT on Code::Blocks 10.05 screenshot

Last Updated: Aug 9th, 2012

1)First thing you need to do is download freeGLUT headers and binaries. You will find them on the freeGLUT website, specifically on this page.

Scroll down to the Prepackaged Releases section and click on the prepackaged windows binaries page.
download

Then download the MinGW binaries archive.
mingw package

Open the zip archive and there should be a folder called "freeglut". Copy that entire folder and put it anywhere you'd like. For these tutorials I'm putting it in a directory I created called C:\mingw_dev_lib

2)Start up Code::Blocks and create a new empty project.
new project

3)Go to project properties.
project properties

4)Now we have to tell Code::Blocks to search for header files in the freeglut folder we just extracted. Go to build options.
build options

In the Search Directories, add a new compiler directory.
search directories

Select the include directory from the folder you extracted.
add directory

And say no when it asks you whether you want it to be a relative path. Now Code::Blocks knows where to find the freeGLUT header files.
added directories

5)Next we are going to tell Code::Blocks to search for library files in the freeGLUT folder we just extracted. All you have to is add the lib directory from the freeGLUT folder you extacted to the linker search directories.
linker directory

6)In order to compile OpenGL and freeGLUT code, we have to tell the Code::Blocks to link against the libraries. Go under Linker Settings and paste

-lOpenGL32 -lglu32 -lfreeglut

into the other linker options field and click OK.
linker

7)Go back to the project properites and under Build Targets select the build type.
build type
I recommend setting it to GUI Application if you don't want console output, and Console Application if you do want console output.

8)When our OpenGL/freeGLUT application runs, the operating system needs to be able to find the dll file.

Go find the freeGLUT folder you extracted and from the bin folder inside copy freeglut.dll and put it either where your executable will run, or inside of the system directory. C:\WINDOWS\SYSTEM32 is the 32bit windows system directory and C:\Windows\SysWOW64 is the 64bit system directory of 32bit applications. For these tutorials, I'm assuming we're making 32bit applications.

9)Now go download the source for lesson 01. Add the source files inside to your project.

Now build. If there are any errors, make sure you didn't skip a step.

Now that you have OpenGL and freeGLUT compiling, it time to go onto part 2 of the tutorial.
The documentation for OpenGL can be found here.
The documentation for GLUT (the API freeGLUT is based on) can be found here.
The documentation for freeGLUT can be found here.

Hello OpenGL Part 2: Your First Polygon