Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Another compiling problem

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    3

    Another compiling problem

    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.

  2. #2
    Intern Contributor
    Join Date
    Mar 2002
    Posts
    61

    Re: Another compiling problem

    I think that the problem is that you didn't specify the wright path for your librairies.
    To do it :

    1-
    >locate libX11
    >locate libXext

    the two commands gives you a path

    2-a.
    first possibility, you had the two path (they may be the same) to your file

    /etc/ld.so.conf

    and execute the commande

    >ldconfig

    which update you ld.cache.It specifies the place where your compiler must look for libraries.

    2-b.
    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).]

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    3

    Re: Another compiling problem

    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.

  4. #4
    Guest

    Re: Another compiling problem

    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.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2002
    Posts
    3

    Re: Another compiling problem

    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.

  6. #6
    Intern Contributor
    Join Date
    Mar 2002
    Posts
    61

    Re: Another compiling problem

    Have you tried the following command :

    echo $LD_LIBRARY_PATH

    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
    >export $LD_LIBRARY_PATH

    try it. It worked on my system.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •