Compiling for Linux
Note if you have forgotten how to use Linux or are new to it please visit Hans-Wolfgang’s Linux Intro which is a self-contained intro to basic linux usage, and it has links to local setup issues (where to click to get a terminal etc).
- Create a new directory called ex2
- Download and unzip zip file and find Example_2_1.cpp, then copy this into a new file simple.cpp in dir ex2
Create simple.cpp and copy in code from simple code
- Note that the code is written for MS Visual Studio so edit simple.cpp and make sure that:
- #include “stdafx.h” is commented out or does not exist
- Change the Microsoft entry point int _tmain(int argc, _TCHAR* argv) to the normal ‘C’ entry point: int main(int argc, char* argv).
- Add GLUT initialisation glutInit(&argc, argv); as the first line in main( ) if it is not there.
- make sure that the line #include <stdio > is included (near the top with the other #include statements)
- Complie using: gcc simple.cpp -o simple -lGLU -lglut -lGL -lm
- Check that your directory now contains the executable file “simple”
- Run “simple” by typing simple or ./simple
- Download and unzip the zip file of all exercises for Microsof Windows
- Locate and copy the desired source code file into a new directory and call it something (e.g. filename.cpp).
- Open in your favorite code editor and comment out the line “#include “stdafx.h”
- Complie using: “gcc filename.cpp -o filename -lGLU -lglut -lGL -lm”
for multiple files such as ex 8.1 use
“gcc filename1.cpp filename2.cpp -o filename -lGLU -lglut -lGL -lm”