Visit Our UNIX and Linux User Community

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

Thread Tools Search this Thread
Operating Systems BSD FreeBSD: /usr/bin/ld not looking in /usr/local/lib
# 1  
Old 01-06-2015
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 script seems to exit without too much trouble:
$ ./
checking for autoconf >= 2.61... found
checking for automake >= 1.8.5... found
checking for found
checking for found
generate configure script... automake-1.14: warnings are treated as errors
po/ warning: wildcard ../src/*.c ../src/*.h: non-POSIX variable name
po/ (probably a GNU make extension)
po/ warning: '%'-style pattern rules are a GNU make extension
po/ warning: '%'-style pattern rules are a GNU make extension
src/ warning: ':='-style assignments are not portable
src/ 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/ (probably a GNU make extension)

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
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.

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_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:
$ ld -lxml2
ld: cannot find -lxml2 is located in /usr/local/lib:
$ ls /usr/local/lib | grep -i libxml2

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?
$ 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

# 2  
Old 01-06-2015
Originally Posted by AntumDeluge
... ... ...
Am I mistaken in thinking that /usr/local/lib is a standard directory for linking to shared libraries in FreeBSD?
... ... ...

/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.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 01-06-2015
If you have

then try
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.

Previous Thread | Next Thread
Test Your Knowledge in Computers #112
Difficulty: Easy
macOS was not the largest Unix largest installed base in 2017.
True or False?

9 More Discussions You Might Find Interesting

1. Solaris

How to link sed from /usr/bin/sed to /usr/local/bin/sed?

Hi Guys, OS:- Solaris 10 64Bit I have a small query. On one server a user is facing sed command issue. He gets error regarding sed for this location /users/hoy/2999/batch5/bin/ /usr/local/bin/sed: not found How ever the sed is actually present at this location on server:-... (13 Replies)
Discussion started by: manalisharmabe
13 Replies

2. Shell Programming and Scripting

/usr/local/bin/expr function not working

Legends, I am not able to set "expr" function in ksh script. Below is the sample code i used, and output is as "Syntax error" Please help me to come out of it. OUTPUT (9 Replies)
Discussion started by: sdosanjh
9 Replies

3. UNIX for Dummies Questions & Answers

Macintosh build error: dyld: Library not loaded: /usr/local/lib/libpcre.0.dylib

Hi all, my first post here. I'm trying to load hypermail on my Mac (Tiger 10.4.11). It seemed to install just fine, but when I run the test build I get this error: dyld: Library not loaded: /usr/local/lib/libpcre.0.dylib Referenced from: /Users/sstark/Desktop/hypermail/tests/../src/hypermail... (4 Replies)
Discussion started by: slugger415
4 Replies

4. AIX

/usr/local/bin/cvs: Not found

I can able to access /usr/local/bin/cvs in the terminal (AIX 6.1 Box). but i am getting the "/usr/local/bin/cvs: Not found " when i call it from the script. please some one assist me what maybe problem (6 Replies)
Discussion started by: hifirockz
6 Replies

5. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

6. UNIX for Dummies Questions & Answers

/usr/local/lib is not searched by by default?

it seems that /usr/local/lib is not searched by by default in fedora14. If so, why some software put its lib files in /usr/local/lib? eg: glib and gtk+. (6 Replies)
Discussion started by: vistastar
6 Replies

7. Solaris

Questions about /usr/local/bin & scripts.

Hi gentlemen. For what intended is the directory /usr/local/bin? In this directory are some script. I don't understand how these scripts being in this directory are started. Each time after registration of the user occurs start of these scripts. These scripts start applications. (7 Replies)
Discussion started by: wolfgang
7 Replies

8. Solaris

How do I link ld in /usr/ucb/ to /usr/ccs/bin?

Hi all, below is the problem details: ora10g@CNORACLE1>which ld /usr/ucb/ld ora10g@CNORACLE1>cd /usr/ccs/bin ora10g@CNORACLE1>ln -s /usr/ucb/ld ld ln: cannot create ld: File exists ora10g@CNORACLE1> how to link it to /usr/ccs/bin? (6 Replies)
Discussion started by: SmartAntz
6 Replies

9. Programming

/usr/bin/ld: warning:, needed by /opt/openmpi/lib/, may

hello, i get these warnings on make(ing) /usr/bin/ld: warning:, needed by /opt/openmpi/lib/, may conflict with /usr/bin/ld: warning:, needed by /usr/lib/gcc/x86_64-redhat-linux6E/4.3.2/../../../liblapack.a, may conflict with... (1 Reply)
Discussion started by: sreekar
1 Replies

Featured Tech Videos