[CMake] new rpath support
Brad King
brad.king at kitware.com
Mon Feb 27 09:54:06 EST 2006
Zachary Pincus wrote:
> Here's what I'm trying to do in a cross-platform way, hopefully with
> cmake. I am creating several shared libraries (python modules,
> actually), which share some runtime code. Thus, each module needs to
> link to a secondary shared object that contains this runtime.
>
> What are my options for making sure that when one of these python
> modules is loaded, the dynamic loader will be able to locate the shared
> runtime module? I see the following, of which (3) seems optimal, except
> that I'm not sure I can do that on windows.
>
> The options:
> (1) Set with PATH (win) or LD_LIBRARY_PATH (unix) environment variable
> to tell the loader where to look. This has to be done before the
> program starts, so the onus is on the user to make sure these are set
> right. That's a pain.
...but it is the accepted way for users to deal with things they install
to their home directories without admin priviledges.
> (2) Install the library to a standard location where the loader knows
> to look. This is /usr/lib or /usr/local/lib on unix. I'm not sure how
> to do this in windows -- does the dll go somewhere and the import
> library go somewhere else? Not sure. Anyhow, globally installing
> something seems nasty (and requires admin privileges).
This will work for those with admin priviledges and for system-provided
packages.
> (3) Install the library in a location with a known relative path to the
> python modules. On OS X, link the *runtime library* with an
> install_name containing this relative path. On other unix, link each
> *python module* with an rpath containing that relative path. (Is this
> right??) On windows... is this even possible?
This may work on OSX if the install_name uses the @executable_path
feature but it will not work in general. RPATH entries cannot be
relative paths because they would be interpreted relative to the current
working directory, not the executable or module location!
The solution on Windows is just to put the runtime DLLs in the same
directory as the modules that need them.
-Brad
More information about the CMake
mailing list