OpenGL: Undefined Reference

Started by
3 comments, last by sab3156 21 years, 5 months ago
When i try to compile a basic OpenGL application, i get the following: _________________________________________________________________ c:\csi\projects\game\maingame.cpp: In function `int WinMain(HINSTANCE__ *, HINSTANCE__ *, CHAR *, int)'': c:\csi\projects\game\maingame.cpp:273: warning: converting NULL to non-pointer type c:\csi\projects\game\maingame.cpp:285: warning: converting NULL to non-pointer type c:\csi\projects\game\maingame.cpp:285: warning: converting NULL to non-pointer type C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0xf):maingame.cpp: undefined reference to `glEnable@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x1f):maingame.cpp: undefined reference to `glClearColor@16'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x2c):maingame.cpp: undefined reference to `glClear@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x34):maingame.cpp: undefined reference to `glLoadIdentity@0'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x39):maingame.cpp: undefined reference to `glFlush@0'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x47):maingame.cpp: undefined reference to `SwapBuffers@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x67):maingame.cpp: undefined reference to `ChoosePixelFormat@8'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x84):maingame.cpp: undefined reference to `SetPixelFormat@12'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x11b):maingame.cpp: undefined reference to `wglCreateContext@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x139):maingame.cpp: undefined reference to `wglMakeCurrent@8'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x15c):maingame.cpp: undefined reference to `wglMakeCurrent@8'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x16d):maingame.cpp: undefined reference to `wglDeleteContext@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x1bd):maingame.cpp: undefined reference to `glViewport@16'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x1ca):maingame.cpp: undefined reference to `glMatrixMode@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x1d2):maingame.cpp: undefined reference to `glLoadIdentity@0'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x204):maingame.cpp: undefined reference to `gluPerspective@32'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x211):maingame.cpp: undefined reference to `glMatrixMode@4'' C:\WINDOWS\TEMP\ccFOVhgb.o(.text+0x219):maingame.cpp: undefined reference to `glLoadIdentity@0'' _________________________________________________________________ what am i supposed to do for this to work?
Air-Conditioners are like computers. They stop working when you open windows.
Advertisement
I gave you the answer here. You must link the libraries. I gave you the switches to link the libraries that you need.

Where do you put the switches? I don't know; you won't tell use what IDE or build system you're using. I'd already jumped to the conclusion that you are using a GCC/MinGW32 system of some kind. Probably Dev C++, but I have no idea what version.

If you are using Dev C++, look for some type of project settings dialog and look for a linkage options textbox. Add the -lopengl32 -lglu32 -lgdi32 text to it.



[edited by - Null and Void on November 5, 2002 5:49:57 PM]
That question cannot be answered if you do not provide us with the name of the compiler you''re using...

A quick fix that may or may not work...try adding:

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

just after your include directives (i.e. #include <somestuff.h>)

_____________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
sorry bout the late reply. im using Dev C++ 4.
Air-Conditioners are like computers. They stop working when you open windows.
Goto "Project"->"Project Options" and add to the Linker Options/Optional Libraries line following:
-lopengl32 -lglu32
(Hope I remember it right now)
I'm not sure special libraries for DevC++ are needed, but them can propably be found at cone3d.gamedev.net
Hope this helps

edit: Just like Null and void already told :D

[edited by - stefu on November 6, 2002 5:04:01 PM]

This topic is closed to new replies.

Advertisement