Unix/Linux Go Back    


BSD BSD, sometimes called Berkeley Unix, is a Unix operating system developed by the Computer Systems Research Group of the UC Berkeley.

FreeBSD: /usr/bin/ld not looking in /usr/local/lib

BSD


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-06-2015
AntumDeluge's Unix or Linux Image
AntumDeluge AntumDeluge is offline
Registered User
 
Join Date: Aug 2014
Last Activity: 12 September 2017, 12:12 AM EDT
Location: Oregon
Posts: 14
Thanks: 5
Thanked 4 Times in 3 Posts
BSD FreeBSD: /usr/bin/ld not looking in /usr/local/lib

I'm not sure if this is the default behavior for the ld command, but it does not seem to be looking in /usr/local/lib for shared libraries.

I was trying to compile the latest version of Kanatest from svn. The autorgen.sh script seems to exit without too much trouble:

Code:
$ ./autogen.sh
checking for autoconf >= 2.61... found
checking for automake >= 1.8.5... found
checking for configure.ac... found
checking for Makefile.am... found
generate configure script... automake-1.14: warnings are treated as errors
po/Makefile.am:2: warning: wildcard ../src/*.c ../src/*.h: non-POSIX variable name
po/Makefile.am:2: (probably a GNU make extension)
po/Makefile.am:20: warning: '%'-style pattern rules are a GNU make extension
po/Makefile.am:23: warning: '%'-style pattern rules are a GNU make extension
src/Makefile.am:2: warning: ':='-style assignments are not portable
src/Makefile.am:2: warning: shell if test -e .svn; then echo -DREV=\"`LC_ALL=C svn info | sed -n '/^Rev/p'| sed -e 's/^Revision:\ //'`\"; fi;: non-POSIX variable name
src/Makefile.am:2: (probably a GNU make extension)
done

I don't think the GNU warnings are related, but I don't know for sure.

Trying to run the generated configure script results in the linker failing to find libxml2.so:

Code:
...
...
checking pkg-config is at least version 0.9.0... yes
checking for GTK... yes
checking for xml2-config... yes
checking for xmlNewDoc in -lxml2... no
configure: error: You do not appear to have libxml2 installed.

config.log:

Code:
...
...
configure:4135: checking for xml2-config
configure:4151: found /usr/local/bin/xml2-config
configure:4163: result: yes
configure:4179: checking for xmlNewDoc in -lxml2
configure:4204: cc -o conftest -g -O2   conftest.c -lxml2   >&5
/usr/bin/ld: cannot find -lxml2
cc: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4204: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Kanatest"
| #define PACKAGE_TARNAME "kanatest"
| #define PACKAGE_VERSION "0.4.10"
| #define PACKAGE_STRING "Kanatest 0.4.10"
| #define PACKAGE_BUGREPORT "pasp@users.sf.net"
| #define PACKAGE_URL ""
| #define PACKAGE "kanatest"
| #define VERSION "0.4.10"
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char xmlNewDoc ();
| int
| main ()
| {
| return xmlNewDoc ();
|   ;
|   return 0;
| }
configure:4213: result: no
configure:4223: error: You do not appear to have libxml2 installed.

Running the ld command on its own has the same result:

Code:
$ ld -lxml2
ld: cannot find -lxml2

libxml2.so is located in /usr/local/lib:

Code:
$ ls /usr/local/lib | grep -i libxml2
libxml2.a
libxml2.so
libxml2.so.2
libxml2.so.2.9.2

I have to add LDFLAGS="-L/usr/local/lib" to the configure line for it to work.

Am I mistaken in thinking that /usr/local/lib is a standard directory for linking to shared libraries in FreeBSD? Or is this pkgconf related?

Code:
$ pkgconf --list-all | grep -i xml
libxml-2.0                     libXML - libXML library version2.
expat                          expat - expat XML parser
xml2po                         xml2po - Tool for translating XML documents
libxml++-2.6                   libxml++ - C++ wrapper for libxml
libplist                       libplist - A library to handle Apple Property Lists whereas they are binary or XML
QtXmlPatterns                  Qtxmlpatterns - Qtxmlpatterns Library
QtXml                          Qtxml - Qtxml Library
Qt5Xml                         Qt5 Xml - Qt Xml module

Sponsored Links
    #2  
Old Unix and Linux 01-06-2015
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 22 September 2017, 3:03 PM EDT
Location: San Jose, CA, USA
Posts: 10,508
Thanks: 542
Thanked 3,675 Times in 3,135 Posts
Quote:
Originally Posted by AntumDeluge View Post
... ... ...
Am I mistaken in thinking that /usr/local/lib is a standard directory for linking to shared libraries in FreeBSD?
... ... ...
Yes.

/usr/local/lib is a conventional place to add local libraries, but it is not a default location for any FreeBSD supplied libraries. And, it is not a directory that is searched by default by ld.
The Following User Says Thank You to Don Cragun For This Useful Post:
AntumDeluge (01-06-2015)
Sponsored Links
    #3  
Old Unix and Linux 01-06-2015
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 22 September 2017, 5:39 PM EDT
Location: Simplicity
Posts: 3,748
Thanks: 306
Thanked 1,257 Times in 1,136 Posts
If you have

Code:
LDFLAGS="-L/usr/local/lib"

then try

Code:
LDFLAGS="-L/usr/local/lib -R/usr/local/lib"

that, if understood by your linker (man ld), might add a hardcoded hint into your binary.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to link sed from /usr/bin/sed to /usr/local/bin/sed? manalisharmabe Solaris 13 01-30-2014 02:09 PM
/usr/local/bin/cvs: Not found hifirockz AIX 6 08-05-2011 12:28 AM
When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)? michellepace OS X (Apple) 1 06-14-2011 04:52 AM
/usr/local/lib is not searched by ld-linux.so by default? vistastar UNIX for Dummies Questions & Answers 6 12-07-2010 12:50 AM



All times are GMT -4. The time now is 08:15 PM.