Boost logo

Boost-Build :

Subject: Re: [Boost-build] darwin dll-path no effect
From: Boris Dušek (boris.dusek_at_[hidden])
Date: 2010-05-23 12:23:51


Found this draft of mine from November, thought it still might help:

On Thu, Oct 22, 2009 at 9:29 AM, Vladimir Prus <ghost_at_[hidden]> wrote:
>
> On Saturday 13 December 2008 Michael Pust wrote:
>
>> hello,
>> i am using boost.build (bundled with boost 1.37.0) to build an
>> application and im noticing that dll-path option has no effect on
>> darwin (gcc-4.0.1 os10.5.5) other than to reorder the build steps. i
>> still have to specify DYLD_LIBRARY_PATH to find my support libraries
>> after install.
>> is this a known problem with this version of boost.build?
>
> I am afraid this is a known problem with OSX. At least, I was not able
> to find any way to achieve an effect similar to -rpath option on Linux.

Hi,

From looking at the documentation, using rpath on OS X involves 2 things on the executable that wants to search some of its dependent dylibs using rpaths:

1. adding an the rpath to the executable
2. enabling the specific dependent dylib entry in the executable to be searched using rpath

1. can be done either by:
a. linker (using the -rpath option)
b. or on a compiled binary using the install_name_tool -add_rpath <new rpath> <executable name>

2. can be done either by:
a. the library itself having the install name of @rpath/<the appropriate path>
b. leaving the library intact and modifying the linked dylib entry in the executable using install_name_tool -change <orig dylib install name> <@rpathed dylib path> <executable name>

From looking on the internet, I found that @rpath is not available on Tiger (10.4).

So it seems unlike on Linux, where -rpath affects all dependent libraries, on OS X you have to do a second step to, enabling a specific dependent dylib entry to be rpath'ed. Maybe that was the problem?

Maybe an even simpler solution to the problem, if you are OK with fixing the path of the dependent library to an absolute path, is to use just step 2. and instead of specifying @rpath/... for the library path, specify directly the path (i.e. install_name_tool -change libboost... /opt/my/stuff/lib/libboost... <executable name>). This will of course work on Tiger.

Also of interest are @executable_path, available since at least Tiger, and @loader_path, available since Tiger, which can often do what you want.
For more details, see man dyld and man install_name_tool.
HTH,
Boris


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk