From owner-freebsd-questions Fri Oct 20 10:58:51 2000 Delivered-To: freebsd-questions@freebsd.org Received: from burlma1-smrt3.gtei.net (burlma1-smrt3.gtei.net [4.2.35.36]) by hub.freebsd.org (Postfix) with ESMTP id 7571B37B663 for ; Fri, 20 Oct 2000 10:58:42 -0700 (PDT) Received: from nemesis.tools.gtei.net (nemesis.tools.gtei.net [4.2.38.28]) by burlma1-smrt3.gtei.net (8.9.3/8.9.3) with ESMTP id RAA25744 for ; Fri, 20 Oct 2000 17:58:41 GMT Received: (from jdiehl@localhost) by nemesis.tools.gtei.net (8.9.3+Sun/8.9.1) id NAA03504 for freebsd-questions@freebsd.org; Fri, 20 Oct 2000 13:58:40 -0400 (EDT) Date: Fri, 20 Oct 2000 13:58:40 -0400 From: Joe Diehl To: freebsd-questions@freebsd.org Subject: linking oddness Message-ID: <20001020135840.P11549@genuity.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I was wondering if someone can help me out here, seeing as I'm now rather lost. I'm having problems with linking libraries that I install in /usr/local/lib. For instance: $ LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/X11R6/lib:/lib $ export LD_LIBRARY_PATH $ gcc -o test test.o -ljpeg /usr/libexec/elf/ld: cannot find -ljpeg $ gcc -o test test.o -L/usr/local/lib -ljpeg $ ldd test test: libjpeg.so.62 => /usr/local/lib/libjpeg.so.62 (0x28064000) libc.so.4 => /usr/lib/libc.so.4 (0x28082000) jdiehl@eros:~$ ls /usr/local/lib/libjpeg* /usr/local/lib/libjpeg.a /usr/local/lib/libjpeg.so /usr/local/lib/libjpeg.la /usr/local/lib/libjpeg.so.62 /usr/local/lib/libjpeg.lai /usr/local/lib/libjpeg.so.9 I'm running FreeBSD 4.1.1-RELEASE I havn't fiddled with gcc/binutils at all: jdiehl@eros:~$ gcc -v Using builtin specs. gcc version 2.95.2 19991024 (release) jdiehl@eros:~$ ld -v GNU ld version 2.10.0 (with BFD 2.10.0) Because of these problems I've tried fiddling with /etc/ld{,-elf}.so.conf: jdiehl@eros:~$ cat /etc/ld-elf.so.conf /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib jdiehl@eros:~$ cat /etc/ld.so.conf /usr/lib/compat/aout /usr/X11R6/lib/aout /usr/local/lib/aout /usr/lib/compath /usr/X11R6/lib /usr/local/lib I did do an `ldconfig -aout; ldconfig -elf` Note that this isn't limited to libjpeg: jdiehl@eros:~$ gcc -o test test.o -ltiff /usr/libexec/elf/ld: cannot find -ltiff jdiehl@eros:~$ gcc -o test test.o -lXau /usr/libexec/elf/ld: cannot find -lXau jdiehl@eros:~$ gcc -o test test.o -lX11 /usr/libexec/elf/ld: cannot find -lX11 Now for some fun with truss: $ truss ld -o test test.o -lc -ljpeg 2>&1 | grep libjpeg open("/usr/lib/libjpeg.so",0,0666) ERR#2 'No such file or directory' open("/usr/lib/libjpeg.a",0,0666) ERR#2 'No such file or directory' $ truss ld -o test test.o -lc -ljpeg 2>&1 | grep libc\. access("/usr/local/lib/libc.so.4",0) ERR#2 'No such file or directory' access("/usr/lib/libc.so.4",0) = 0 (0x0) open("/usr/lib/libc.so.4",0,027757774730) = 3 (0x3) open("/usr/lib/libc.so",0,0666) = 5 (0x5) Right so.. It'll look for libc in /usr/local/lib like my LD_LIBRARY_PATH asks; however, it ignores my LD_LIBRARY_PATH for libjpeg? I notice that FreeBSD uses ld.so.conf for a.out and ld-elf.so.conf for elf binaries, is there something differant I need for elf linking besides LD_LIBRARY_PATH? From the ld(1) manpage: -Lsearchdir This command adds path searchdir to the list of paths that ld will search for archive libraries. You may use this option any number of times. The default set of paths searched (without being specified with -L) depends on what emulation mode ld is using, and in some cases also on how it was configured. The paths can also be specified in a link script with the SEARCH_DIR command. Ok so I'm going to try this, though I'm not sure about exactly sure what format is expected in SEARCH_DIR: $ SEARCH_DIR="/usr/local/lib:/usr/lib:/usr/X11R6/lib" $ export SEARCH_DIR $ gcc -o test test.o -ljpeg /usr/libexec/elf/ld: cannot find -ljpeg $ SEARCH_DIR="-L/usr/local/lib" $ export SEARCH_DIR $ gcc -o test test.o -ljpeg /usr/libexec/elf/ld: cannot find -ljpeg Any thoughts? I'm not on this list, so please cc: any replies to me. Thanks :) -- Joe Diehl (jdiehl@genuity.net) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message