• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to make a program look for dylibs other than /usr/local/lib?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make a program look for dylibs other than /usr/local/lib?


  • Subject: Re: How to make a program look for dylibs other than /usr/local/lib?
  • From: Peter O'Gorman <email@hidden>
  • Date: Fri, 07 Dec 2007 02:03:21 -0600

Graham Reitz wrote:
> Thanks Peter that definitely has me in the right direction.
>
> Ok I can see the problem using otool -L
>
> The executable is still looking in the /usr/local/lib for the
> libmysqlpp.2.dylib file.  I changed the Runpath Search Paths variable
> (-rpath) to a directory with the location of the libmysqlpp.2.dylib
> file(s) but it's not changing where the executable is looking for the
> dylib.  Is there a way to change that at compile/link time?


When you created libmysqlpp.2.dylib, it was done, probably with
./configure; make; sudo make install so the prefix was set to /usr/local
, so it has an install_name of /usr/local/lib/libmysqlpp.2.dylib. You
will also have trouble with /sw/lib/mysql/libmysqlclient_r.15.dylib,
which was, I assume, built by fink.

The install_name is encoded in the library, it is like an soname on ELF
systems, except the install_name is usually an absolute path. If you
create a library with just the basename as the install_name (e.g the
install_name is libmysqlpp.2.dylib) then the dynamic linker will look
for it only in DYLD_FALLBACK_LIBRARY_PATH
($(HOME)/lib:/usr/local/lib:/lib:/usr/lib by default).

For this reason Apple originally came up with @executable_path. If you
set the install_name of the library to
@executable_path/libmysqlpp.2.dylib and relink your executable then the
dynamic linker will look for it in the same directory as the executable.

With 10.4 @loader_path was introduced, which allowed you to have
libraries reference each other relative to themselves rather than the
main executable.

And with 10.5 comes @rpath. If the install_name of your library is
@rpath/libmysqlpp.2.dylib and you link your executable with,
-Wl,-rpath,/home/graham/lib -Wl,-rpath,../lib -Wl,-rpath,. then th
dynamic linker will look for libmysqlpp.2.dylib in each dir in turn
until it finds it.

In each case, if you change the install_name of the library itself using
install_name_tool -id you must relink everything that uses the library
or change the references in the users too with install_name_tool -change.

This is all fairly well documented in the manpages for dyld(1) dyld(3)
ld(1), otool(1) and install_name_tool(1).

Peter
--
Peter O'Gorman
http://pogma.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to make a program look for dylibs other than /usr/local/lib?
      • From: "parag vibhute" <email@hidden>
References: 
 >How to make a program look for dylibs other than /usr/local/lib? (From: Graham Reitz <email@hidden>)
 >Re: How to make a program look for dylibs other than /usr/local/lib? (From: Peter O'Gorman <email@hidden>)
 >Re: How to make a program look for dylibs other than /usr/local/lib? (From: Graham Reitz <email@hidden>)

  • Prev by Date: Creating / Editing Xcode project templates.
  • Next by Date: Re: remembering cursor position
  • Previous by thread: Re: How to make a program look for dylibs other than /usr/local/lib?
  • Next by thread: Re: How to make a program look for dylibs other than /usr/local/lib?
  • Index(es):
    • Date
    • Thread