LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ld Madness! Won't search ld.so.conf (https://www.linuxquestions.org/questions/linux-software-2/ld-madness-wont-search-ld-so-conf-76139/)

kauffman 07-26-2003 02:42 PM

ld Madness! Won't search ld.so.conf
 
Hey all,
I've been wrestling with ld for the last few days as I try to compile the BlackBox Window manager. I cannot get ld to link anything to the XFree86 libraries in /usr/X11R6/lib. My /etc/ld.so.conf includes the path /usr/X11R6/lib and I have run ldconfig numerous times to update /etc/ld.so.cache. But ld doesn't seem to be searching the paths in ld.so.config. Here is an example of my woes:

$ cat test.c
#include "confdefs.h"

int main() {
XtMalloc()
; return 0; }
$ gcc -c test.c
$ ld test.o -lXt
ld: cannot find -lXt
$ ld --verbose test.o -lXt
...(Skipping to first section of output)
attempt to open test.o succeeded
test.o
attempt to open /usr/i386-redhat-linux/lib/libXt.so failed
attempt to open /usr/i386-redhat-linux/lib/libXt.a failed
attempt to open /usr/lib/libXt.so failed
attempt to open /usr/lib/libXt.a failed
attempt to open /usr/local/lib/libXt.so failed
attempt to open /usr/local/lib/libXt.a failed
attempt to open /lib/libXt.so failed
attempt to open /lib/libXt.a failed
ld: cannot find -lXt
-------

So I'm wondering now why none of the paths in ld.so.conf aren't showing up as places that ld tries searching.

A few details that might be pertinent:
- ld is apparently by default using "elf_i386" emulation. I can't get it to emulate the other supported version "i386linux" because the script isn't included in my system (Redhat 9 - starting to think it's not all it's cracked up to be).
- In my X11R6/lib directory, there are no symbolic links of the form libX*.so All the libraries have only the actual library with the major and minor versions, or a symbolic link with the major version. Example: libXt.so.6 (link to ->) libXt.so.6.0
- Even when I manually include the path with -L/usr/X11R6/lib -lXt, the library still isn't found.
- Only when I add a symbolic link of the form libX*.so and inlcude -L/usr/X11R6/lib is the library found.

It seems like my build environment has been mucked up. Anyone care to try to diagnose what's going on?

Thanks,
Chris Kauffman

jpbarto 07-26-2003 03:01 PM

I'm going to try and install blackbox on my machine and let you know the results... in the meantime check libXt.la if such a thing exists.

these little text files can muck up ldconfig at times.

jpbarto 07-26-2003 03:12 PM

kauffman, I just downloaded and compiled blackbox 0.65.

after ./configure ; make not once did it try to link anything with libXt... it looks like all it linked to was libX11... did you build with some configure options or something?

Corin 07-26-2003 04:14 PM

ld.so, ld-linux.so* - dynamic linker/loader

ld.so.conf is the conf file for ld.so, the dynamic linker/loader

At run time of the executable, the dynamic linker looks in the ld.so.cache file to find where the dynamic link libraries are located.

But what you are trying to do is to compile and link the source
code to create the executable.

The libXt.so library is usually in the standard location /usr/X11R6/lib,
which is not in the standard path of /lib and /usr/lib known to gcc and
ld, so when linking objects for an X11 program you have to include
a parameter as to where the object file is to be found.

man ld

-Lsearchdir
--library-path=searchdir
Add path searchdir to the list of paths that ld will search for
archive libraries and ld control scripts. You may use this option
any number of times. The directories are searched in the order in
which they are specified on the command line. Directories speci-
fied on the command line are searched before the default directo-
ries. All -L options apply to all -l options, regardless of the
order in which the options appear.


so you would do

ld -L /usr/X11R6/lib -lXt -lX11

If you are going to be building a few programs like this,
then it is a good idea to write a Makefile and you include
all the necessary header include directories and library paths
in macro variables.

#+---------------------------------------------------------------------------+#
#| Include file paths. |#
#+---------------------------------------------------------------------------+#

INCLUDES = -I$(MOTIFHOME)/include -I$(OPENWINHOME)/include

#+---------------------------------------------------------------------------+#
#| Link flags. |#
#+---------------------------------------------------------------------------+#

LFLAGS = -lXm -lgen -lXt -lX11 -lnsl

#+---------------------------------------------------------------------------+#
#| Library file paths. |#
#+---------------------------------------------------------------------------+#

LIBS = -L$(MOTIFHOME)/lib -L$(OPENWINHOME)/lib

#+---------------------------------------------------------------------------+#
#| Compiler flags. |#
#+---------------------------------------------------------------------------+#

CFLAGS = $(ANSI) $(DEBUG) $(OPTIMIZE) $(STRIP) $(DEFINES) \
$(INCLUDES) $(LFLAGS) $(LIBS)

etc etc

kauffman 07-27-2003 02:08 AM

Workaround or something...
 
Hey all,
I guess the trick is to have the XFree86 development packages installed. This allows gcc and ld to find the proper libraries to link to. For all you RPMers out there, thats the XFree86-devel rpm. Once I installed that package, everything was hunkey-dorey.
The reason I was trying to compile with libXt was that the configure for Black Box was crapping out on a test for X11 where it attempted to link to libXt (at least according to the config.log, this was what was happening). Thanks for posting, and if you ever have trouble linking to X11 libraries, make sure the development versions are on your system.

-K


All times are GMT -5. The time now is 05:49 PM.