I am just getting started, so apologies for what is probably a basic question. I am using Redhat Linux 7.2 with a Voodoo3 graphics card. I am trying to compile the very first example from the book “OpenGL for the X Window System”. (I am unfamiliar with how X windows works and fairly new to Linux). The line I type to compile the program is:
cc -o glxsimple glxsimple.c -lGL -lXext -lX11
The problem I have is that the linker (ld) fails to find the “Xext” library and also fails to find the “X11” library. Funnily enough, there is no problem with the actual OpenGL stuff eg it finds the “GL” library and so forth. This makes me think perhaps the X libraries are called something different under Redhat linux 7.2. Would that be the case, and if so, can you tell me what to modify my the references to “X11” and “Xext” to? Many thanks.
Thanks for your suggestions, but they did not seem to do the trick. When I typed “locate”, I discovered that I had all the libraries I need, however when I type out the long versions, for example, in trying to compile the glutsphere program, I end up with another strange error. As follows:
[root@localhost glutsphere]# cc -o glutsphere glutsphere.c -lglut -lGLU -lGL -L/usr/X11R6/include/X11/Xmu -L/usr/X11R6/include/X11/extensions/ -L/usr/X11R6/include/X11
glutsphere.c: In function main': glutsphere.c:49: warning: return type ofmain’ is not int' /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libGL.so: undefined reference topow’
collect2: ld returned 1 exit status
This is using the actual code supplied by the book which downloaded off the net - so there are no typing mistakes. Any thoughts would be welcome. Thanks.
MPech is absolutley right, the remaining error is a math function so you need to add -lm. The warning explains itself but you can ignore it. You can also remove your -L to the include directories.
Thank you very much! Your advice worked. I do have one question though, which is, how to I get my compiler to automatically link in the /usr/X11R6/lib libraries (and other libraries). I have edited the ld.so.conf file and there was already a reference to this directory. I have also run the ldconfig command. It does not seem to make a difference. Any ideas? Doesn’t matter if you cannot be bothered answering, I’m pretty happy to have got thus far.