How To Install Dev-C++ and GLUT
How To Install Dev-C++ and GLUT
13/04/12 11:03
When the download is complete, click on the "open" button to start the installation process. (Or go to C:\Temp
andDouble click on devcpp4.9.9.2_setup.exe). You will see a few screens that ask you to pick a language
(English) and to agree to the license terms. Choose a "typical" installation.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 1 of 15
13/04/12 11:03
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 2 of 15
13/04/12 11:03
Answer "yes" when it asks if you wish to install Dev-cpp for all users. Note: if the installation fails, re-install and
try "no" for this.
A screen says the installation is complete:
Keep the check mark in the box. Click on "Finish". A first-time configuration screen appears:
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 3 of 15
13/04/12 11:03
Pick "English" and "New Look". In the next several screens, hit "Yes" for its suggestions.
II. DEV-C++ starts up. Try out the installation with a simple C program.
Details:
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 4 of 15
13/04/12 11:03
Click File/New/Project. Pick a name for the project (such as "myProject"). Click "C Project". Click on "Empty
Project". Click "OK".
In "Create New Project", click "save" (later on you will probably want to create separate subdirectories for your
various projects.).
Click "File/New/Source File" and in "Add source file to current project" click "Yes". You now get a screen where
you can edit the source file.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 5 of 15
13/04/12 11:04
Type in a simple C program, as below. Now click "File/Save As" and save the file as "hello.c" (or other name.)
Important: be sure that the file extension is .c. With any other extension (such as the suggested .cpp) you will
have problems compiling.
At this point, the compiler and development environment has been installed. You should find Dev-C++ listed
under "Programs" on the "Start" menu and will now be able to write, compile, and run C (and C++) programs.
You will have include files, libraries, and dll's for OpenGL (and all other standard packages) but not GLUT.
GLUT manages the windows and other user interface components needed for OpenGL programming, and
needs to be separately installed.
If you do not need GLUT , you can quit now.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 6 of 15
13/04/12 11:04
Double click on glutming.zip (or otherwise unzip it). You will see the files that are in the zip archive. (Your unzipping program will probably be diferent than the one shown here, but should work about the same.)
Click on "Extract" to extract all the subdirectories and files. Pick some convenient directory to extract them to
(perhaps C:\temp\glutming). You only need three files, but extract all of them anyway.
Only three of the files in the various subdirectories are needed. Each of the three files should be put in a
subdirectory with other files of its type. Use Explorer to move the files to where they are needed.
Note: If you only see some of these files listed in Explorer, click on "View/Options/View" and then select the
radio button "Show all Files".
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 7 of 15
13/04/12 11:04
To here:
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 8 of 15
13/04/12 11:04
To here:
The directory to use should also have the files glu32.dll and opengl32.dll. These should have
come with your operating system.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 9 of 15
13/04/12 11:04
c. Start a new project by clicking File/New/Project. In the panel that pops up, name the project something like
"rectangle", click on "empty project" and "C": Click OK.
Note: For compiling with OpenGL you must create a project. You need to have a project (not just a single C file)
in order to link in the OpenGL libraries.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 10 of 15
13/04/12 11:04
d. In the next panel, navigate to your folder C:\GLproject, and click "Save".
e. In Dev-C++, click "File/New/Source File" and then in the next panel "Add to Project" click "yes". Click
"File/Save As" and then give the file a name. Navigate to your project subdirectory to save the file in it. Name
the file something like "rectangle.c"
Be sure that the file names ends with ".c" anything else will cause big problems.
f. Click and drag your mouse over the following program so that it is highlighted, then click "Edit/Copy" from the
browser's menu bar.
#include <GL/glut.h>
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 11 of 15
const int
A = 500;
const float B = 500;
const float C = 200;
13/04/12 11:04
void myinit(void)
{
glClearColor(0.7, 0.7, 0.7, 0.0); /* gray background */
glMatrixMode(GL_PROJECTION);
/* In World coordinates: */
glLoadIdentity();
/* position the "clipping rectangle" */
gluOrtho2D( -B/2, B/2, -B/2, B/2);/* at -B/2, its right edge at +B/2, its bottom */
glMatrixMode(GL_MODELVIEW);
/* edge at -B/2 and its top edge at +B/2 */
}
void display( void )
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_POLYGON) ;
glColor3f ( 1.0, 0.3, 0.2);
glVertex2f( -C/2, -C/2 );
glVertex2f( C/2, -C/2 );
glVertex2f( C/2, C/2 );
glVertex2f( -C/2, C/2 );
glEnd();
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitWindowSize( A, A );
*/
*/
*/
*/
glutMainLoop();
*/
g. Now click in the editing window of Dev-cpp and then click "Edit/Paste" in its menu bar. The program will
appear in the editing window.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 12 of 15
13/04/12 11:04
h. Click "File/Save". The file in your project directory should now contain an OpenGL program.
i. Tell Dev-cpp what libraries need to be linked. Click "Project/Project Options".
j. Now click "Parameters". Click the "Add Library or Object" button and navigate to the libraries that should be
added, found under C:\Dev-cpp\lib
../lib/libopengl32.a
../lib/libglu32.a
../lib/libglut32.a
Add them in that order (only). Notice that the slashes will appear in Unix style "/" rather than DOS-style "\".
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 13 of 15
13/04/12 11:04
When you are done adding the three libaries, you should see:
The exact pattern of "../../.." you see depends on how deep in the directory structure your source file lies.
Click "OK".
k. Click "Execute/Compile and Run". The program should compile, link, and run:
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 14 of 15
13/04/12 11:04
If things don't work (very common) click on the "Compile Log" tab for some confusing error messages. If you
see something like the following, it means that you made a mistake in adding the libraries to the project:
Try to fix the list of libraries, or perhaps start over from scratch.
You now are finished, or have given up.
http://chortle.ccsu.edu/Bloodshed/howToGL.html
Page 15 of 15