[Linker error] Undefined reference to 'gl***'

There seems to be problem with linkin my program during the compilation.

make.exe -f “C:\Documents and Settings\Ketil\My Documents\Programmering\C++\OpenGLTest\Makefile.win” all
g++.exe main.o -o “OpenGLTest.exe” -L"C:/Dev-Cpp/lib"

This is what Dev-C++ 4.9.8.0 writes during the compilation. I’ve includet gl.h and glu.h. OpenGL32.lib, OpenGL.lib and glu32.lib is in my lib folder. (C:/Dev-Cpp/lib).

I recieve this:
main.o(.text+0x1b):main.cpp: undefined reference to `glViewport@16’
and alot more of them (35 to be exact!)

What may be the problem?

append to your make statement this:

-lOpenGL32 -lGlu32

[those are lowercase L’s]

:regards:

Originally posted by Anklebiter:
[b]There seems to be problem with linkin my program during the compilation.

make.exe -f “C:\Documents and Settings\Ketil\My Documents\Programmering\C++\OpenGLTest\Makefile.win” all
g++.exe main.o -o “OpenGLTest.exe” -L"C:/Dev-Cpp/lib"

This is what Dev-C++ 4.9.8.0 writes during the compilation. I’ve includet gl.h and glu.h. OpenGL32.lib, OpenGL.lib and glu32.lib is in my lib folder. (C:/Dev-Cpp/lib).

I recieve this:
main.o(.text+0x1b):main.cpp: undefined reference to `glViewport@16’
and alot more of them (35 to be exact!)

What may be the problem?[/b]

Thanks. But I still recieve 3 more errors…

main.o(.text+0x6fd):main.cpp: undefined reference to ChoosePixelFormat@8' main.o(.text+0x72e):main.cpp: undefined reference toSetPixelFormat@12’
main.o(.text+0xc43):main.cpp: undefined reference to `SwapBuffers@4’

All these should be in the OpenGl32 library, so therefor I can’t understand why I recieve them…

Those are windows functions, try -lwin32 or something similar, I don’t know the switch for the Windows gcc port offhand, as I haven’t used that compiler for quite some time. Should be in the documentation somewhere though.

I have had the same problem… Try using this linker line:

-lopengl32 -lglaux -lglu32 -lglut32 -gdi32 -mwindows

That basically covers most of the Things used in opengl other that -lglut32…

Also try adding the wingdi.h to your header, I think that is what it is called…

BTW, Are you following a tutorial or a book or anything like that?

Also try reading this topic: http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_to pic;f=2;t=016637

For those of you that are still interrested… in Dev-CPP under the lib directory there is a library called libgdi32.a

Linking to this library should cure the linker errors for SwapBuffers, ChosePixelFormat, and SetPixelFormat.