View Full Version : Includes incomplete?

12-11-2003, 03:55 PM
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 http://www.opengl.org/discussion_boards/ubb/frown.gif

TIA for any help provided.

--Andrew M Dietz

12-11-2003, 08:57 PM
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 libGL.so lives on your system.

12-12-2003, 12:12 AM
[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 to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccKcLHlL.o(.text+0x71): In function `__tcf_0':
: undefined reference to `std::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/../../../libGL.so: undefined reference to `pow'
collect2: ld returned 1 exit status

well, its a different error! maybe this one wont be so hard to fix http://www.opengl.org/discussion_boards/ubb/wink.gif thanks for the help wit hteh -lGL option!

12-12-2003, 11:59 AM
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.

12-12-2003, 03:54 PM
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!