Sign in to follow this  
chickencoop

RED BOOK compile error?

Recommended Posts

Im looking for some help, I purchased the red book and am trying to compile the first example. and I get the following error. Can someone tell me where im going wrong
E:\c++\OPENGL RED BOOK\chapter_1\simple\src>g++ main.cpp
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x14e): undefined r
eference to `glEnable@4'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x186): undefined r
eference to `glClear@4'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x18e): undefined r
eference to `glLoadIdentity@0'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x1cc): undefined r
eference to `gluLookAt@72'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x1db): undefined r
eference to `glBegin@4'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x206): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x228): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x253): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x275): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x2a0): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x2c2): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x2ca): undefined r
eference to `glEnd@0'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x2d6): undefined r
eference to `glBegin@4'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x301): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x323): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x34e): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x370): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x39b): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x3bd): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x3e8): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x40a): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x435): undefined r
eference to `glColor4f@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x457): undefined r
eference to `glVertex3f@12'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x45f): undefined r
eference to `glEnd@0'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x497): undefined r
eference to `glViewport@16'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x4a6): undefined r
eference to `glMatrixMode@4'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x4ae): undefined r
eference to `glLoadIdentity@0'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x4d8): undefined r
eference to `gluPerspective@32'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x4e7): undefined r
eference to `glMatrixMode@4'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x4ef): undefined r
eference to `glLoadIdentity@0'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x557): undefined r
eference to `SDL_Init'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x5ac): undefined r
eference to `SDL_GL_SetAttribute'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x5c0): undefined r
eference to `SDL_GL_SetAttribute'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x5d4): undefined r
eference to `SDL_GL_SetAttribute'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x5e8): undefined r
eference to `SDL_GL_SetAttribute'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x5fc): undefined r
eference to `SDL_GL_SetAttribute'
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x610): more undefi
ned references to `SDL_GL_SetAttribute' follow
C:\Users\Owner\AppData\Local\Temp/ccGs9VMa.o:main.cpp:(.text+0x6bf): undefinecol
lect2: ld returned 1 exit status

Share this post


Link to post
Share on other sites
That can't be the only output from ld, what's the complete error message? In fact, what's the entire output that you get when you execute your command. My guess is that you're also getting a "can't find library" message...

Share this post


Link to post
Share on other sites
It is the complete error message
the following is what i get


E:\c++\OPENGL RED BOOK\chapter_1\simple\src>g++ -lglu32 -lopengl32 -lSDL main.cpp
collect2: ld returned 1 exit status

E:\c++\OPENGL RED BOOK\chapter_1\simple\src>

Im thinking maybe i have one of those computers that has become self aware, and out of protest has decided it will not compile until it gets better pay and conditions. :)

[Edited by - chickencoop on November 11, 2009 11:10:25 PM]

Share this post


Link to post
Share on other sites
Ok I got it working I can now compile chapter 1, It was a linking problem For those who are interested.

i compiled chapter 1 with the following command

g++ -o program.exe main.cpp -lmingw32 -lSDLmain -lSDL -lopengl32 -lglu32

Now I have another question.


I tried compling chapter 2 with the same command and again I get the same error.

so my question now is what libraries do people link in for chapter 2 of the red book?

Share this post


Link to post
Share on other sites
Hard to guess without seeing the code and/or the book (since you bought it I assume you are not using the 1.1 version). Does it use any functions that start in glut* or wgl* or some other stuff besides standard OpenGL and GLU?

Share this post


Link to post
Share on other sites
Glut no
Wgl yes.
From searching through the code in the example, calls X11

Its the 2nd edition of the red book



[Edited by - chickencoop on November 18, 2009 1:09:23 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this