LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 07-26-2003, 02:42 PM   #1
kauffman
LQ Newbie
 
Registered: May 2003
Distribution: Redhat 9
Posts: 2

Rep: Reputation: 0
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
 
Old 07-26-2003, 03:01 PM   #2
jpbarto
Senior Member
 
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
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.
 
Old 07-26-2003, 03:12 PM   #3
jpbarto
Senior Member
 
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
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?
 
Old 07-26-2003, 04:14 PM   #4
Corin
Member
 
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446

Rep: Reputation: 31
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
 
Old 07-27-2003, 02:08 AM   #5
kauffman
LQ Newbie
 
Registered: May 2003
Distribution: Redhat 9
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Webcam madness!! donjcook Linux - Hardware 3 11-13-2005 02:27 PM
search default: search post title only slackie1000 LQ Suggestions & Feedback 4 03-10-2005 07:50 AM
resolv.conf search line dunkyb Linux - Networking 4 01-28-2005 01:50 AM
Quick VIM question (unhighlighting search terms after search) lrt2003 Linux - Newbie 5 05-08-2004 05:21 PM
Simple resolve.conf question (Search Command) rrosenkoetter Linux - Networking 2 04-05-2004 07:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration