maybe gl is not installed in the default lib directory path, try to add -L /usr/X11R6/lib in your command line.
If still don’t work, try to check where gl libraries are installed and modify the -L in accordance.
You’re in luck. I’m sitting on an SuSE 11.3 box right now, with the NVidia OpenGL drivers installed, and I find:
> ls -l /usr/lib64/libGL.so* /usr/lib/libGL.so*
lrwxrwxrwx 1 root root 10 Oct 29 08:35 /usr/lib/libGL.so -> libGL.so.1
lrwxrwxrwx 1 root root 18 Oct 29 08:35 /usr/lib/libGL.so.1 -> libGL.so.260.19.14
-rwxr-xr-x 1 root root 757412 Oct 29 08:35 /usr/lib/libGL.so.260.19.14
lrwxrwxrwx 1 root root 10 Oct 29 08:35 /usr/lib64/libGL.so -> libGL.so.1
lrwxrwxrwx 1 root root 18 Oct 29 08:35 /usr/lib64/libGL.so.1 -> libGL.so.260.19.14
-rwxr-xr-x 1 root root 980368 Oct 29 08:35 /usr/lib64/libGL.so.260.19.14
/usr/lib64 is for 64-bit libs. /usr/lib is for 32-bit libs.
When you specify -lGL on the link line, that tells GCC to go searching the system library directories for a file named libGL.so. As you can see, it finds it in /usr/lib64 directory (for a 64-bit build). And that daisy chains to libGL.so.1 and onto libGL.so.260.19.14, which is the actual library file.
Also, if you don’t have a vendor-specific GL driver installed, looks like the “Mesa” package is what provides the libGL.so symlink:
gcc -o file file.cpp -lglut -lGL -lGLU
I read this error:
gcc: lGL No such file or directory.
This error is not possible given the command you specified. So one or the other is wrong. “lGL No such file …” would imply that you put -llGL on the link line. It should be -lGL. -l being the option and GL being the base library name (libGL.so being the full name).