Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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?
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. |#
#+---------------------------------------------------------------------------+#
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.