Public Group

# OpenGL not working in Dev-C++

This topic is 4427 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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.

##### Share on other sites
Oh, thanks dude, sorts it out appart from "`gluPerspective@32'", which library's that in?

##### Share on other sites
Try adding -lglu32 as well. Not 100% sure of this one.

##### Share on other sites
thats awsome thanks :D

##### Share on other sites
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.

##### Share on other sites
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 <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glext.h>
#include <gl/glut.h>

These functions are referenced starting from openGL 1.5... Help!

##### Share on other sites
@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.

##### Share on other sites
@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

##### Share on other sites
It isn't the linking order the symbols are not being defined properly.

You need to use extensions. Try this library GLee.

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632959
• Total Posts
3009476
• ### Who's Online (See full list)

There are no registered users currently online

×