Discussion:
[CMake] Removing rpath paths
Gonzalo Garramuño
2018-10-28 13:19:58 UTC
Permalink
This is probably something very simple, but I cannot find the answer. I
would like to remove all references to rpath and have my executable and
libraries be controlled by LD_LIBRARY_PATH. According to the wiki,
that's the default behavior. However, I am finding it does not work so
I set several options and nothing seems to work. I think I might have
stumbled into a bug in the libstdc++, but want to check:

Currently I have:

# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

# the RPATH to be used when installing
SET(CMAKE_INSTALL_RPATH "")

# don't add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

I compile my code on an Ubuntu 12.04.5 box for compatibility reasons.

When I install on an Ubuntu 16.04 which I also compile for, the error of
my executable I get is the following:

/usr/local/mrViewer-v4.3.1-Linux-64/bin/mrViewer: relocation error:
/usr/local/lib/libIlmCtl.so.1.5.0: symbol
_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE version
GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

If I remove /usr/local/lib/libIlmCtl.so.1.5.0 from its location my
executable works. I am also shipping a version of libstdc++.so.6 with
my executable, which might be a little weird.

The questions I would like some clarification are:

1) Do all the libs that my executable links to should have the rpath
removed?

2) Why when I install an executable without rpath:

Set runtime path of "/usr/local/bin/exrmultiview" to ""

I can still run it even if LD_LIBRARY_PATH is unset?

3) Why does running 'readelf -d myexecutable | grep RPATH' returns nothing
--
Gonzalo Garramuño
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Alexander Neundorf
2018-10-28 16:59:18 UTC
Permalink
On 2018 M10 28, Sun 10:19:58 CET Gonzalo Garramuño wrote:
...
Post by Gonzalo Garramuño
3) Why does running 'readelf -d myexecutable | grep RPATH' returns nothing
only grep for "PATH", then you also get the newer RUNPATH entry.

Alex
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Gonzalo Garramuño
2018-10-28 17:20:40 UTC
Permalink
Post by Alexander Neundorf
...
Post by Gonzalo Garramuño
3) Why does running 'readelf -d myexecutable | grep RPATH' returns nothing
only grep for "PATH", then you also get the newer RUNPATH entry.
Alex
Thanks.  I tried it but it also shows nothing.  In principle I don't
have any rpath.  However, in behavior I do.


--

Gonzalo Garramuño
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Alexander Neundorf
2018-10-28 21:32:52 UTC
Permalink
Post by Alexander Neundorf
...
Post by Gonzalo Garramuño
3) Why does running 'readelf -d myexecutable | grep RPATH' returns nothing
only grep for "PATH", then you also get the newer RUNPATH entry.
Alex
Thanks. I tried it but it also shows nothing. In principle I don't
have any rpath. However, in behavior I do.
well, then you do have some RPATH/RUNPATH somewhere ;-). As you say probably
in the libraries.
ld.so.conf could also contains additional search directories, but I doubt that
that's the case for you.

Alex
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Gonzalo Garramuño
2018-10-28 21:46:24 UTC
Permalink
Post by Alexander Neundorf
well, then you do have some RPATH/RUNPATH somewhere ;-). As you say probably
in the libraries.
ld.so.conf could also contains additional search directories, but I doubt that
that's the case for you.
Yes, I found two libraries with rpath in them.  I used the commandline:

chrpath -d library

to remove it.  Now all is fine with the world.
--
Gonzalo Garramuño
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Alexander Neundorf
2018-10-29 21:17:05 UTC
Permalink
Post by Gonzalo Garramuño
Post by Alexander Neundorf
well, then you do have some RPATH/RUNPATH somewhere ;-). As you say
probably in the libraries.
ld.so.conf could also contains additional search directories, but I doubt
that that's the case for you.
chrpath -d library
to remove it. Now all is fine with the world.
Ok.
Then actually you shouldn't need any RPATH settings.
The default by cmake is that you get the full RPATH in the build tree and an
empty RPATH in the install tree.

Alex
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Loading...