[CMake] RPATH not set for "first" build library

Martin Vogt mvogt1 at gmail.com
Sat Aug 25 11:52:35 EDT 2012


Hello,

I have a library "A", which dlopens another library "B".

But this does not work with cmake under the following circumstances:

- in tree build
- library in another directory

I have attached an example for the behaviour.

The reason for this is, that cmake does not set the RPATH in library A,
and thus dlopen does not work on library B:

library A:

>readelf -d build/libmyopen.so
>[..]
> 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
> 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
> 0x000000000000000e (SONAME)             Library soname: [libmyopen.so]
> 0x000000000000000c (INIT)               0x648

The working version is a library A1

>readelf -d build/libmyopen1.so
> 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
> 0x000000000000000e (SONAME)             Library soname: [libmyopen1.so]
> 0x000000000000000f (RPATH)              Library rpath: [/tmp/rpath_not_set_in_first_lib/build]
> 0x000000000000001d (RUNPATH)            Library runpath: [/tmp/rpath_not_set_in_first_lib/build]
> 0x000000000000000c (INIT)               0x678

The only difference between library A and library A1 is that
A1 is the "second" library in the cmake projekt.
Whereas "second"means, that A1 is linked against an arbitatry
other library in the project.

This is from the demo project in the attachment:

[/tmp/rpath_not_set_in_first_lib]$./build/works
dlopen start
[/tmp/rpath_not_set_in_first_lib]$./build/works_not
dlopen start
libdummy.so: cannot open shared object file: No such file or directory
[/tmp/rpath_not_set_in_first_lib]$

If this is a bug, I can open a bug report for this.

regards,

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rpath_not_set_in_first_lib.tgz
Type: application/x-gzip
Size: 692 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120825/5ef9bb48/attachment.bin>


More information about the CMake mailing list