Includes incomplete?

I have all the following files in my GL subdirectory for my includes

GLwDrawA.h fglut.h glui.h glxproto.h viewmodel.h
GLwDrawAP.h gl.h glut.h glxtokens.h xmesa.h
GLwMDrawA.h gl_mangle.h glutf90.h moo.cpp xmesa_x.h
GLwMDrawAP.h glaux.h glx.h moo.cpp~ xmesa_xf86.h
algebra3.h glext.h glx_mangle.h osmesa.h
arcball.h glsmap.h glxext.h quaternion.h
fgl.h glu.h glxint.h stdinc.h
fglu.h glu_mangle.h glxmd.h tube.h

but when I compile a simple application with nothing except glBegin( GL_POINTS ); and glEND() I always get

/tmp/ccNQpAvJ.o(.text+0x16): In function main': : undefined reference to glBegin’
collect2: ld returned 1 exit status

I even tried copying and pasting all the code from GL/gl.h into the source file that I called glBegin and glEnd from, but I still always get the same error. Only by editing the soruce to give a body to teh glBegin and glEnd functions in GL/gl.h do the errors go away. Am I missing some sort of include file that has the definitions for those functions??

Having a very hard time trying to learn OpenGL programming if I cant use any of the functions

TIA for any help provided.

–Andrew M Dietz

You need to link with the GL library by adding ‘-lGL’ to your link line. You may also need to add the path using the -L option. Either -L/usr/X11R6/lib or -L/usr/lib depending on where lives on your system.

[allanon@Paranor projects]# gcc -lGL -L/usr/include/c++/3.2.2/ -o test test.cpp
/tmp/ccKcLHlL.o(.text+0x42): In function __static_initialization_and_destruction_0(int, int)': : undefined reference tostd::ios_base::Init::Initin-charge
/tmp/ccKcLHlL.o(.text+0x71): In function __tcf_0': : undefined reference tostd::ios_base::Init::~Init in-charge
/tmp/ccKcLHlL.o(.eh_frame+0x11): undefined reference to __gxx_personality_v0' /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2.2/../../../ undefined reference topow’
collect2: ld returned 1 exit status

well, its a different error! maybe this one wont be so hard to fix thanks for the help wit hteh -lGL option!

If you’re going to link a C++ program, you need to use the C++ compiler (i.e., g++). That should fix the new errors.

Haha I never use gcc for c++ programs … I dont know why I did that one time … and didn’t pick up on it.

Everything compiles fine now. I appreciate your help!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.