Public Group

# OpenGL not working in Dev-C++

This topic is 4336 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
2. 2
Rutin
25
3. 3
4. 4
JoeJ
18
5. 5
gaxio
11

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631765
• Total Posts
3002213
×
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.22742527723312378, "perplexity": 7483.424213848264}, "config": {"markdown_headings": true, "markdown_code": false, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-30/segments/1531676592001.81/warc/CC-MAIN-20180720232914-20180721012914-00113.warc.gz"}