Computer Science Canada

Getting OpenGL/GLUT to work

Author:  102jon [ Wed Dec 15, 2010 5:25 pm ]
Post subject:  Getting OpenGL/GLUT to work

Hi, I'm working on my first graphics project using the Codeblocks IDE with MinGW compiler. I recently downloaded freeglut for windows. In my source code I made sure to include the GL/glut.h file, however I receive this error message upon compiling:


ld.exe||cannot find -lglut32|
||=== Build finished: 1 errors, 0 warnings ===|

Any insight would be greatly appreciated.

Author:  102jon [ Wed Dec 15, 2010 5:28 pm ]
Post subject:  Re: Getting OpenGL/GLUT to work

Correction, my compiler is GNU GCC.

Author:  TerranceN [ Wed Dec 15, 2010 5:31 pm ]
Post subject:  RE:Getting OpenGL/GLUT to work

Thats a linker error. Basically glut.h defines classes, and functions, etc which are then implemented in the glut32.lib file. -lglut32 just tells the linker that you need to include the glut32.lib file in the executable. The problem it is having is just as it says, it cannot find glut32.lib. In codeblocks, go Settings->Compiler and Debugger->Search Directories->Linker and make sure the glut32.lib file is in one of those directories.

Author:  102jon [ Wed Dec 15, 2010 5:37 pm ]
Post subject:  Re: Getting OpenGL/GLUT to work

When I downloaded freeglut, the only .lib file there is freeglut.lib. Did I download the wrong windows binary or something?

Author:  TerranceN [ Wed Dec 15, 2010 6:10 pm ]
Post subject:  RE:Getting OpenGL/GLUT to work

Whoops, my eyes jumped over the part where you mentioned freeglut. Freeglut uses freeglut.lib, but in order to make it compatible with other people's code, the creators decided to use the same name as glut's header file, "GL/glut.h".Well if the lib is freeglut.lib you should be able to use the linker option -lfreeglut to link with it. And you can always use Settings->Compiler and Debugger->Linker->Link Libraries because you show Codeblocks both the library and its directory.


: