How To Compile GLUT on Windows


Please read the directions all the way through before you start.
  1. Install MS Visual C++ .

    After installing VC++, make sure that you can compile and run a simple "hello world" console application program.

    Also make sure that you have "opengl32.lib" on your system somewhere inside the VC++ directory tree. Doing a "find files" should help you locate it. If you don't have "opengl32.lib", then you can install it using the VC++ setup program.

    After the install, you should check to make sure that your autoexec.bat file contains a line like "call vcvars32.bat". If it does not, you need edit your autoexec.bat file and put that line there with the appropriate path to the vcvars32.bat file. Doing a "find files" should help you locate vcvars32.bat.

    Finally, after making sure that "call vcvars32.bat" is in your autoexec.bat file, reboot your computer and continue.

    If all has gone well then you should be able to open up a command prompt and type: 
    cl <enter> 
    and a Microsoft Copyright and usage message should be displayed.

  2. Download and unzip glut37.zip and glut37data.zip .

    Caution: You should unzip these files with an unzip program which understands long filenames or GLUT may fail to compile. The wiz502xN.exe program will unzip the GLUT files correctly.

    Also be sure to unzip the files into the same directory. In whatever directory you pick, the unzip program should make a subdirectory called "glut-3.7" which contains the files from both glut37.zip and glut37data.zip .

  3. Compile GLUT.

    Open a command prompt and change into the "glut-3.7" directory where you unzipped the glut files from the previous step. 
    Type: 
    glutmake <enter> And you should see the glut library begin to compile. Depending on the speed of your computer, this could take between 10 and 60 minutes.

    If the compile fails immediately, then something probably went wrong in one of the previous steps.

    Eventually the build may fail but usually the required library files are built and can be put into place.

  4. Install the GLUT library and header files.

    If the compile of glut was successful then you should find glut32.dll and glut32.lib in the "glut-3.7\lib\glut" directory.

    I like to make a directory called "c:\local" and then "c:\local\include" and "c:\local\lib" to hold the extra library files which I use. You can place them anywhere you like, but I'll assume that you're doing things the way that I do and that you've made the directories as I have above.

    Copy glut32.dll and glut32.lib into "c:\local\lib".

    Make the directory "c:\local\include\gl" and copy "glut-3.7\include\gl\glut.h" and "glut-3.7\include\gl\glsmap.h" and "glut-3.7\include\gl\tube.h" into it.

  5. Final Notes:

    You should now have everything installed to compile GLUT based OpenGL programs. To compile GLUT assignments, you need to remember to tell VC++ where to find the GLUT header and library files. You can do that by clicking project -> settings... and then choosing the "C/C++" tab.

    In that pane there is a "category" drop box. Choose the "preprocessor" category. In the "additional include directories" box, put the path to the "gl" directory which contains "glut.h". For example, if you put glut.h in "c:\local\include\gl\glut.h" you would type in "c:\local\include"

    Now choose the "link" tab of the dialog box. Choose the "input" category. In the "additional library path" box put the path to the directory containing "glut32.lib". For example, if you put glut32.lib into "c:\local\lib" then you would put "c:\local\lib" in the "additional library path" box.

    Now your GLUT based OpenGL code should compile and link.

    It is important that "glut32.dll" is in your path. If it is not, GLUT programs will not work. One way to put it in your path is to edit your autoexec.bat file and put the path to it in there. Another is to copy it into the "c:\windows\system32" directory.

    Now try compiling this little glut skeleton program glutskel.zip

你可能感兴趣的:(How To Compile GLUT on Windows)