[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Woody linker/compiler problem



	Hello!

I have a problem with linking under latest woody/i686. I first contacted 
Christopher C. Chimelis because I thought the problem is in the binutils.

-------

Let's say I have a simple program sdltest.c (the ones are usually used by
./configure script).

#include <SDL.h>
int main(int argc, char **argv) {
        return 0;
} // main()

gcc -o sdltest sdltest.c `sdl-config --cflags` `sdl-config --libs`
won't compile because there are undefined references to libX11 functions. 

Just for the record sdl-config --cflags provides the following:
-I/usr/include/SDL -D_REENTRANT
and sdl-config --libs provides:
-L/usr/lib -lSDL -lpthread -L/usr/X11R6/lib -lXxf86dga -lXxf86vm -lXv

It only compiles after I put all the referenced libs *from /usr/X11R6/lib*
on the command line explicitly like:

gcc -o sdltest sdltest.c `sdl-config --cflags` `sdl-config --libs` -lX11
-lXext

The problam is that linker can't find libraries from /usr/X11R6/lib by
itself. There's no problem with libs from /lib or /usr/lib. They get
automaticly linked.  

josef:~/programming/c/test$ ldd sdltest
        libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0x40022000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x4009d000)
        libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x400b3000)
        libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4018e000)
        libc.so.6 => /lib/libc.so.6 (0x4019c000)
        libdl.so.2 => /lib/libdl.so.2 (0x402be000)
        libm.so.6 => /lib/libm.so.6 (0x402c2000)
        libasound.so.1 => /usr/lib/libasound.so.1 (0x402e4000)
        libartsc.so.0 => /usr/lib/libartsc.so.0 (0x402fc000)
        libesd.so.0 => /usr/lib/libesd.so.0 (0x40303000)
        libaudiofile.so.0 => /usr/lib/libaudiofile.so.0 (0x4030a000)
        libggi.so.2 => /usr/lib/libggi.so.2 (0x40328000)
        libgii.so.0 => /usr/lib/libgii.so.0 (0x40333000)
        libgg.so.0 => /usr/lib/libgg.so.0 (0x4033a000)
        libvga.so.1 => /usr/lib/libvga.so.1 (0x40340000)
        libaa.so.1 => /usr/lib/libaa.so.1 (0x4039e000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
        libslang.so.1 => /lib/libslang.so.1 (0x403b9000)
        libgpm.so.1 => /usr/lib/libgpm.so.1 (0x4041a000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x40420000)

I don't remember having this problems back on potato. People using other
distributions don't have this problem either.

Can this be resolved in any way?

-------

This is the original post I sent to Christopher. He said he never had any
problems whatsoever. Also other people I asked have no problems with this
kind of linking/compiling. 

I also tried adding -Wl,-rpath,/usr/X11R6/lib and it compiles without any
problem. But with -Wl,-L,/usr/X11R6/lib it doesn't work either.

In the 'man ld' there is a long list (1 to 8) of items that are searched
for libs at link time. But on my system this is not the case. -L doesn't
get searched and neither /etc/ld.so.cache is examined for the missing
libs.  

josef:/etc# cat /etc/ld.so.conf
/usr/X11R6/lib
/usr/local/lib

This is what i am getting in the gcc(ld) output:

/usr/bin/ld: warning: libX11.so.6, needed by /usr/lib/libSDL.so, not found
(try using -rpath or -rpath-link)
/usr/bin/ld: warning: libXext.so.6, needed by /usr/lib/libSDL.so, not
found (try using -rpath or -rpath-link)

Why should I try -rpath? Why is it so much better than -L?

I am sorry to ask things that I don't know anything about, but this is
going on for a while now and is getting me pretty pissed.  

Sorry for a long post.

Thanks and take care,

	Miha...



Reply to: