Problems With Dyld: Ld_library_path

abhatia

Registered
Hi,
I am using g++ 3.3 on os X 10.3.9. I have created my own library
using
ar ruv *.o files

After this I try to compile a test program using,
g++ -pg -O -Wno-deprecated -ansi -pedantic -o test test.C
-DANSI_HEADERS -D_G_HAVE_BOOL -I. -I/ALLINCLUDEDIRS -lmylib -llpsolve51
-lm -L.

And the compilation works fine.
But when i try to run the executable ./test, I get the following error
message:

dyld: ./test_grid can't open library: liblpsolve51.dylib (No such file
or directory, errno = 2)
Trace/BPT trap

The library liblpsolve.dylib is NOT located in the current directory. I tried checking the value of LD_LIBRARY_PATH using echo$LD_LIBRARY_PATH, but nothing showed up.

It seems that LD_LIBRARY_PATH is not set, and moreover I am not even sure if it is used on darwin? On posting to a newsgroup, I was told that I need DYLD_LIBRARY_PATH instead. On doing echo $DYLD_LIBRARY_PATH I do not see any paths. Isn't a default value set for them already?

How can I resolve this problem?

thanks,
amit.
 
abhatia said:
It seems that LD_LIBRARY_PATH is not set, and moreover I am not even sure if it is used on darwin? On posting to a newsgroup, I was told that I need DYLD_LIBRARY_PATH instead. On doing echo $DYLD_LIBRARY_PATH I do not see any paths. Isn't a default value set for them already?

DYLD_LIBRARY_PATH is used on Mac OS X instead of LD_LIBRARY_PATH (on Linux, IRIX etc.). It is searched by the dynamic linker if set, otherwise DYLD_FALLBACK_FRAMEWORK_PATH (/Library/Frameworks:/Network/Library/Frameworks:/System/Library/Frameworks) and DYLD_FALLBACK_LIBRARY_PATH ($(HOME)/lib:/usr/local/lib:/lib:/usr/lib) will be searched.

From the "dyld" man page:

Code:
       [B]DYLD_FALLBACK_FRAMEWORK_PATH[/B]
              This  is  a  colon  separated  list  of directories that contain
              frameworks.  It is used as the default location  for  frameworks
              not found in their install path.

              By    default,    it   is   set   to   /Library/Frameworks:/Net-
              work/Library/Frameworks:/System/Library/Frameworks

       [B]DYLD_LIBRARY_PATH[/B]
              This is a colon  separated  list  of  directories  that  contain
              libraries.  The dynamic linker searches these directories before
              it searches the default locations for libraries. It  allows  you
              to test new versions of existing libraries.

              For  each  library that a program uses, the dynamic linker looks
              for it in each directory in DYLD_LIBRARY_PATH  in  turn.  If  it
              still  can't  find  the  library,  it  then  searches DYLD_FALL-
              BACK_FRAMEWORK_PATH and DYLD_FALLBACK_LIBRARY_PATH
              in turn.

              Use the -L option to otool(1).  to discover the  frameworks  and
              shared libraries that the executable is linked against.

       [B]DYLD_FALLBACK_LIBRARY_PATH[/B]
              This  is  a  colon  separated  list  of directories that contain
              libraries.  It is used as the default location for libraries not
              found  in  their  install  path.   By  default,  it  is  set  to
              $(HOME)/lib:/usr/local/lib:/lib:/usr/lib.
 
Back
Top