please help

I am quite a newbie to OpenGL on linux, so please help.My problem:
I downloaded MesaLib 5.0 and MesaDemos 5.0 and I installed them.After that I installed the latest drivers from Nvidia for my Geforce 2 Mx.The drivers works fine (TuxRacer ran smooth) but when I tried them neither the examples in MesaDemos nor Jeff Molofee’s examples didn’t compile, gcc saying something about undefined reference to ‘foo’ in libGLU.so and libOSMesa.so.
How can I make it work?

You don’t need Mesa when using the drivers from NVIDIA (which also contain GL.h, GLU.h and libraries)

Remove Mesa (including the symlinks), install NVIDIA driver + GLX, and try it again.

Also, when you’re talking about ‘Linux’, please mention what distribution you’re using.

I have Mandrake 9.0, and yes I need Mesa because it contains Glut, and I do OpenGL with Glut.

You don’t need Mesa for Glut.

If I don’t need Mesa, then what I need?

You dont need mesa for OGL devel on linux but its helpfull to have since it comes with alot of OGL libs that nvidia dosnt come with. Ive found alot of times OGL programs dont work with the make files so from NeHe get the glut demos, go into konsole, cd into the src dir, then type
g++ main.cpp -B /usr/X11R6/lib -o program -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lpthread
then ./program and it should run.

Every glut program I try to compile I get undefined reference to variables in libGLU.so.It’s very frustrating.Should I uninstall nvidia drivers?Though I want hardware acceleration.

Originally posted by Zork:
Every glut program I try to compile I get undefined reference to variables in libGLU.so.It’s very frustrating.Should I uninstall nvidia drivers?Though I want hardware acceleration.

Are you saying it doesn’t link with GLU when use a glut program? And it links with GLU when you don’t use glut?

Hmm, make sure you are linking to -lglut and -lGL before linking to -lGLU. That’s a long shot but maybe it will. Make sure you have a copy of GLU somewhere.

$ locate GLU
/usr/lib/libGLU.so.1
/usr/lib/libGLU.so
/usr/X11R6/lib/libGLU.so.1
/usr/X11R6/lib/libGLU.so.1.3
/usr/X11R6/lib/libGLU.a
/usr/X11R6/lib/libGLU.so

Hmm, interesting. I wonder which version of GLU my programs link with?

$ ldd demo
libGL.so.1 => /usr/lib/libGL.so.1 (0x40013000)
libGLU.so.1 => /usr/lib/libGLU.so.1 (0x40061000)
libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0x400dd000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40167000)
libIL.so.1 => /usr/lib/libIL.so.1 (0x40197000)
libILU.so.1 => /usr/lib/libILU.so.1 (0x4028c000)
libILUT.so.1 => /usr/lib/libILUT.so.1 (0x402a1000)
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x402a7000)
libm.so.6 => /lib/i686/libm.so.6 (0x40359000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4037b000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
libGLcore.so.1 => /usr/lib/libGLcore.so.1 (0x40383000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40815000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40824000)
libdl.so.2 => /lib/libdl.so.2 (0x40902000)
libpng.so.2 => /usr/lib/libpng.so.2 (0x40905000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x40927000)
libtiff.so.3 => /usr/lib/libtiff.so.3 (0x40945000)
libmng.so.1 => /usr/lib/libmng.so.1 (0x40987000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
libz.so.1 => /usr/lib/libz.so.1 (0x409cc000)

OK. So for the programs that work run a ldd on the executable to figure out why it is working. Then maybe you can figure out why your glut programs don’t work.

The program I am tying to compile is NeHe’s lesson02, glut version.
Compiling with:

gcc -Wall -I/usr/X11R6/include -o lesson2 -L/usr/X11R6/lib lesson2.o -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm

output errors:

/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/…/…/…/libGLU.so: undefined reference to operator new[](unsigned)' /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/../../../libGLU.so: undefined reference tovtable for __cxxabiv1::__si_class_type_info’
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/…/…/…/libGLU.so: undefined reference to operator delete(void*)' /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/../../../libGLU.so: undefined reference to__gxx_personality_v0’
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/…/…/…/libGLU.so: undefined reference to __cxa_pure_virtual' /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/../../../libGLU.so: undefined reference tovtable for __cxxabiv1::__class_type_info’
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/…/…/…/libGLU.so: undefined reference to operator delete[](void*)' /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/../../../libGLU.so: undefined reference tovtable for __cxxabiv1::__vmi_class_type_info’
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/…/…/…/libGLU.so: undefined reference to `operator new(unsigned)’
collect2: ld returned 1 exit status
make: *** [lesson2] Error 1

locate GLU:

/usr/share/doc/libMesaGLU1-4.0.3
/usr/share/doc/libMesaGLU1-4.0.3/COPYRIGHT
/usr/share/doc/libMesaGLU1-4.0.3/COPYING
/usr/share/doc/libMesaGLU1-4.0.3/README.X11
/usr/share/doc/libMesaGLU1-4.0.3/README
/usr/X11R6/lib/libGLU.so.1.3.403
/usr/X11R6/lib/libGLU.so.1

ldd glxgears:

libGL.so.1 => /usr/lib/libGL.so.1 (0x40023000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40070000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40080000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x4014b000)
libm.so.6 => /lib/i686/libm.so.6 (0x4015f000)
libc.so.6 => /lib/i686/libc.so.6 (0x40182000)
libGLcore.so.1 => /usr/lib/libGLcore.so.1 (0x402a2000)
libdl.so.2 => /lib/libdl.so.2 (0x40734000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Can you figure out what is wrong?

Recompile using g++ not gcc

Very weird!I compiled the program with g++ like Oldman advised me and it actually compiled.But why the program compiles with g++ and it doesn’t with gcc?It is written in c not c++.Anyone knows how can I could make gcc to compile the program?
Thanks Oldman!

The program is not in C… its in C++. The absence of classes does not mean that is written in C… The operator new and delete are c++ only. As GLU ueses C++ your application must be compiled and linked with g++

Whoops. Nevermind.

[This message has been edited by jmg (edited 12-13-2002).]

But why most makefiles make use uf gcc inestead of g++?

Some versions of gcc automaticaly detected when it was a c++ file and called g++. But this has been removed from 3.2 version of gcc.

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