View Full Version : Another compiling problem
03-30-2002, 08:50 PM
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.
03-31-2002, 01:47 AM
I think that the problem is that you didn't specify the wright path for your librairies.
To do it :
the two commands gives you a path
first possibility, you had the two path (they may be the same) to your file
and execute the commande
which update you ld.cache.It specifies the place where your compiler must look for libraries.
Second possibility specify these path at the compiling time, for example :
-L/usr/X11R6/lib -lglut -lGLU -lGL -lX11 -lXmu -lXext -lXt -lXi
I hope it will help.
[This message has been edited by MPech (edited 03-31-2002).]
03-31-2002, 02:47 PM
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 of `main' is not `int'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libGL.so: undefined reference to `pow'
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.
04-02-2002, 02:10 AM
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.
Have a great day.
04-02-2002, 04:16 AM
Have you tried the following command :
it must match the path specified in your file ld.so.conf
if it doesn't you must export it to your system.
I think it might be something like :
>LD_LIBRARY_PATH = /usr/X11R6/lib
try it. It worked on my system.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.