<div dir="ltr"><div>I'm having an issue with the RPATH not showing up for one of my shared libraries on OSX. Basically, I end up with a "bare" rpath to one of my shared libraries (i.e., no path prefix) when I check my binary using otool - L<br>
<br></div><div>Specifically, I have a project with a structure that looks like this<br><br>project/module_A<br>project/module_B<br><br></div><div>I'm trying to build "Module B", which depends on a shared library I build in "Module A". (I also use several other shared libraries, but all of them are in system paths, i.e., /usr/local and /usr/lib.). What ends up happening is that all of the rpaths are set *except* for my shared library from Module A (for both the build and install versions of the binary).<br>
<br></div><div>After carefully reading the CMake primer on RPath handling here:<br><br></div><div><a href="http://www.cmake.org/Wiki/CMake_RPATH_handling" target="_blank">http://www.cmake.org/Wiki/CMake_RPATH_handling</a><br>
<br>I tried the suggestion under "Always full rpath", i.e., my CMakeLists.txt file has the following:<br>
<br><pre style="margin-left:40px"># 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)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# 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 TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
</pre><br>However, this still doesn't appear to be setting the RPATH variable for my dynamic library. I likewise checked that CMAKE_INSTALL_RPATH is set correctly (i.e., the library from Module A sits in that directory). However, nothing I do seems to prefix an RPATH directory to my shared library for Module A. <br>
<br>One other thing - I've also tried building this code on Linux (Ubuntu-12.10), and I've noticed that the same configuration correctly sets the RPATH for Module A - so this seems to be specific to OSX. <br><br>
What am I missing here? Going through the list archives, I've seen this problem pop up a few times with respect to OSX, but I haven't really seen anything that specifically solves this issue. Specifically, this message from a few weeks ago seems to be running into the exact same issue, but I don't see any replies:<br>
<br><a href="http://www.cmake.org/pipermail/cmake/2013-January/053335.html">http://www.cmake.org/pipermail/cmake/2013-January/053335.html</a><br><br>The only other thread I've seen on this recently is here:<br><br><a href="http://www.cmake.org/pipermail/cmake/2011-April/043888.html">http://www.cmake.org/pipermail/cmake/2011-April/043888.html</a><br>
<br>The solution here was pretty much to either use install_name_tool manually (which does work, but it requires one to do it each time you build) or to use BundleUtilities. However, I noticed that CMake runs install_name_tool on its own for a library which is built with Module B (i.e., I have libModuleB_core.dylib which is built and linked into the moduleB binary); i.e., this shows up in cmake_install.cmake. So shouldn't there be some way to get CMake to appropriately run install_name_tool for me for Module A as well? Or at the very least, is there a reason no RPATH is being appended to Module A?<br>
<br>Thanks.<br><br>-Steve<br clear="all"></div><div><div><div><div><div>---</div><div>Steve Skutnik, Ph.D.</div>
<div><a href="http://neutroneconomy.blogspot.com/" target="_blank">http://neutroneconomy.blogspot.com</a></div></div>
</div></div></div></div>