Problem with openGL compilation

Hello, reading the tutorial on the site openglbook.com on chapter one, but cannot seem to compile the first program, i have set up freeglut, ect. I am using mingw and compiling under windows.

compile with:
g++ Chapter1.cpp -o Chapter.1.exe -Wall -mwindows glut32.lib -lopengl32

Output:

C:\Users\SC\AppData\Local\Temp\cc7Qo9aj.o:Chapter1.cpp:(.text+0x13b): undefined reference to `_imp__glutInitContextVersion@8'
C:\Users\SC\AppData\Local\Temp\cc7Qo9aj.o:Chapter1.cpp:(.text+0x14c): undefined reference to `_imp__glutInitContextFlags@4'
C:\Users\SC\AppData\Local\Temp\cc7Qo9aj.o:Chapter1.cpp:(.text+0x15d): undefined reference to `_imp__glutInitContextProfile@4'
C:\Users\SC\AppData\Local\Temp\cc7Qo9aj.o:Chapter1.cpp:(.text+0x176): undefined reference to `_imp__glutSetOption@8'
collect2: ld returned 1 exit status
Last edited on
The error "Undefined Reference" means exactly that, you are trying to reference a function without having defined it first. The first three functions are defined in "freeglut_init.c" which is in the ".../freeglut-2.8.0/src" folder, you need to include this in your project so that your IDE knows to compile it. You are correct, it is a little asinine that this website which purports to be a tutorial did not mention this critical piece of information, but at least you now have your answer now.

On another note. the last function listed here "_imp__glutSetOption@8" is not listed in the source files nor is it exported by the DLL's you should be using in this project, it also isn't in the "Chapter 1" tutorial on this site: http://openglbook.com/the-book/chapter-1-getting-started/#toc-step-by-step so is it a typo on your part?

Still working on glutSetOption() function, I will be back shortly
Last edited on
The function "glutSetOption()" is defined in "freeglut_state.c" which is another file you need to include in your project in order for it to compile. This one is again located in ".../freeglut-2.8.0/src". Good luck and feel free to ask any follow up questions.
Try http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/
I suppose that they already provide you with a library. There is no need to keep recompiling in every project.
Topic archived. No new replies allowed.