Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL not working in Dev-C++

Started by yonni Sep 5, 2006 at 9:53 AM 8 replies 3.8k views
Original Post
yonni
yonni
I Downloaded this first tutorial for OpenGL from nehe.gamedev.net (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01 to be precise). I downloaded the version for Dev-C++, opened it, and after attempting to compile the compier gave me:
Quote:
C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x38):lesson1.cpp: undefined reference to glViewport@16' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x45):lesson1.cpp: undefined reference to glMatrixMode@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x4d):lesson1.cpp: undefined reference to glLoadIdentity@0' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x84):lesson1.cpp: undefined reference to gluPerspective@32' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x91):lesson1.cpp: undefined reference to glMatrixMode@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x99):lesson1.cpp: undefined reference to glLoadIdentity@0' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0xb7):lesson1.cpp: undefined reference to glShadeModel@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0xd1):lesson1.cpp: undefined reference to glClearColor@16' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0xe0):lesson1.cpp: undefined reference to glClearDepth@8' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0xf0):lesson1.cpp: undefined reference to glEnable@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x100):lesson1.cpp: undefined reference to glDepthFunc@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x115):lesson1.cpp: undefined reference to glHint@8' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x13b):lesson1.cpp: undefined reference to glClear@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x143):lesson1.cpp: undefined reference to glLoadIdentity@0' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x258):lesson1.cpp: undefined reference to wglMakeCurrent@8' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x282):lesson1.cpp: undefined reference to wglDeleteContext@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x8ce):lesson1.cpp: undefined reference to wglCreateContext@4' C:\DOCUME~1\JOHN-M~1\LOCALS~1\Temp\cc0mcaaa.o(.text+0x914):lesson1.cpp: undefined reference to wglMakeCurrent@8'
Am I going have to define all of those myself? If so, how? And if not, what's wrong?
PurpleAmethyst
PurpleAmethyst
You are not linking to the OpenGL libary. You need to add -lopengl32 to the compiler command line, I can't exactly remember where to put this in the DevC++ IDE because i haven't used it in a while.
yonni
yonni
Oh, thanks dude, sorts it out appart from "`gluPerspective@32'", which library's that in?
yonni
yonni
thats awsome thanks :D
Hobbesian
Hobbesian
Yep, that'll fix it. Took me ages to figure that one out. Just in case there are others with the same problem, in DevCpp the linker commands need to be put into the ProjectOptions->Parameters->Linker box.
sirbone72
sirbone72
Well, I have one more problem with Dev-C++. I'm trying and compile a simple example using buffers. THe problem is that the compiler doesn't find a definition for library functions glGenBuffers(), glBufferData() and for constants GL_ARRAY_BUFFER and GL_STATIC_DRAW.

my include section is

#include
#include
#include
#include
#include

These functions are referenced starting from openGL 1.5... Help!
PurpleAmethyst
PurpleAmethyst
@sirbone72 - I think you need to load these as extensions. Not 100% sure on how to do this off the top of my head, but the headers are usually only for OpenGL 1.1 not 1.5. So anything else you need to load as an extension. I think there are libraries for this called GLEW and GLee.

One thing you need to remember about DevC++ is that DevC++ is not actually a compiler but an IDE for the GCC/MinGW complier so the command line syntax for is the same as for GCC. If you look at man pages and doc for GCC you'll find out how these work.
kire
kire
@sirbone72: You could try a different linking-sequence, however I'm not sure that will solve this problem. Also: are you sure your library-files are updated?

for example, I get reference errors if I use this:
-lSDL
-lSDLmain

it has to be
-lSDLmain
-lSDL
PurpleAmethyst
PurpleAmethyst
It isn't the linking order the symbols are not being defined properly.

You need to use extensions. Try this library GLee.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.