linking problem

i am new to UNIX and OpenGL environment.

if i complie my C++ program like the following line

g++ program.cpp -lGL -lGLU -lglut

i am getting errors like
GLU library not found eventhough i included
those .h files in the program

Try adding ‘-L/usr/X11R6/lib’ to your command line.

use this
g++ program.cpp -B /usr/X11R6/lib -o program -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lpthread -Wno-deprecated

then to execute

./program

Originally posted by fenris:
Try adding ‘-L/usr/X11R6/lib’ to your command line.

still error is occuring when i compile like
rainbow:~$ g++ i.cpp -B /usr/X11R6/lib -o program -lX11 -lXi -lXmu -lglut -lGL
-lGLU -lm -lpthread -Wno-deprecated
ld: fatal: library -lGL: not found
ld: fatal: library -lGLU: not found
ld: fatal: File processing errors. No output written to program
collect2: ld returned 1 exit status
g++: file path prefix `/usr/X11R6/lib’ never used

Originally posted by nukem:
[b]use this
g++ program.cpp -B /usr/X11R6/lib -o program -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm -lpthread -Wno-deprecated

then to execute

./program[/b]

still error is occuring when i compile like
rainbow:~$ g++ i.cpp -B /usr/X11R6/lib -o program -lX11 -lXi -lXmu -lglut -lGL
-lGLU -lm -lpthread -Wno-deprecated
ld: fatal: library -lGL: not found
ld: fatal: library -lGLU: not found
ld: fatal: File processing errors. No output written to program
collect2: ld returned 1 exit status
g++: file path prefix `/usr/X11R6/lib’ never used

Originally posted by arameshnaidu:
[b] still error is occuring when i compile like
rainbow:~$ g++ i.cpp -B /usr/X11R6/lib -o program -lX11 -lXi -lXmu -lglut -lGL
-lGLU -lm -lpthread -Wno-deprecated
ld: fatal: library -lGL: not found
ld: fatal: library -lGLU: not found
ld: fatal: File processing errors. No output written to program
collect2: ld returned 1 exit status
g++: file path prefix `/usr/X11R6/lib’ never used

[/b]

Try -L/usr/X11R6/lib instead of -B /usr/X11R6/lib !

If that dosnt work goto command(while still in X) and type glxgears or try q3a ut ut2003 (the linux version). If those dont run/you have have it. That means ogl hasnt been installed on your system. What you have to do is goto mesa3d.sf.net and download and install that.

Try the following:

g++ program.cpp -L/usr/X11R6/lib -o program -lglut -lGLU -lGL -lXi -lXmu -lX11 -lm

Note:

  1. -L is the option for library path spec (man is your friend - try ‘man g++’). Note that there is no space between -L and the path spec. The glu library is often installed in /usr/X11R6/lib which is not a default search location for g++ compiler/linker. That is why it has to be specified. The opengl lib is usually in /usr/lib which is a default search location.

  2. Note the link order: The library glut builds on glu and gl and must be listed before either one of them. Similarly glu must come before gl.

probaly, you don’t have this libraries(libGL.so/a, libGLU.so/a, libglut.so/a)…

Try to install it first(from linux CD’s, www.Mesa3d.org(sw), or videoboard vendor).

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