<div dir="ltr">The macOS install_name_tool can be used to change the RPATH of your binaries.  It can also be used to set the path for each of the libraries to be loaded.  For a python module I compile, I copy each of its dylib into the appropriate directory relative to my shared library.  I then use the install_name_tool to change from an absolute path to a path relative to @loader_path.<div><br></div><div><table class="gmail-highlight gmail-tab-size gmail-js-file-line-container" style="box-sizing:border-box;border-spacing:0px;border-collapse:collapse;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"></tr><tr style="box-sizing:border-box"><td id="gmail-LC65" class="gmail-blob-code gmail-blob-code-inner gmail-js-file-line" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre">install_name_tool -change <span class="gmail-pl-smi" style="box-sizing:border-box">$j</span> <span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>@loader_path/../gcc/<span class="gmail-pl-s" style="box-sizing:border-box"><span class="gmail-pl-pds" style="box-sizing:border-box">`</span>basename <span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(36,41,46)">$j</span><span class="gmail-pl-pds" style="box-sizing:border-box">`</span></span><span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span> <span class="gmail-pl-smi" style="box-sizing:border-box">$i</span></td></tr><tr style="box-sizing:border-box"><td id="gmail-L66" class="gmail-blob-num gmail-js-line-number" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(27,31,35,0.3);text-align:right;white-space:nowrap;vertical-align:top"></td></tr></tbody></table>where $j is the full path output from "otool -L" and "@loader_path/../gcc" would point to a directory "gcc" relative to the directory containing my python module.<br><br>For a binary executable, I would explore placing required dylib files into a directory relative to @executable_path.<br><br>Regards,</div><div><br></div><div>Juan<br><br class="gmail-Apple-interchange-newline"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 11, 2019 at 4:33 PM Michael Jackson <<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Already looked on google and at the CMake documentation but everything listed does not seem to work so here is the setup.<br>
<br>
I am using MKL and I have a home grown FindMKL since there isn’t an official one. Inside that is the typical find_library() calls which will find the libraries just fine. One of those libraries is a dynamic library (.dylib). Using otool -L on that library the install_name is encoded as @rpath. <br>
<br>
Now I have my add_executable(foo…) and target_link_libraries (Foo ${MKL_LIBRARIES} ).<br>
<br>
Everything compiles and links fine. The issue is at runtime. The app will not launch because libmkl_rt.dylib is not loaded because the path to that library is not encoded into the executable.<br>
<br>
639:[mjackson@ferb:ifort-release]$ otool -l Bin/EMsoftWorkbench.app/Contents/MacOS/EMsoftWorkbench | grep "path"<br>
         name @rpath/libEbsdLib.dylib (offset 24)<br>
         name @rpath/libmkl_rt.dylib (offset 24)<br>
         name @rpath/QtOpenGL.framework/Versions/5/QtOpenGL (offset 24)<br>
         name @rpath/QtNetwork.framework/Versions/5/QtNetwork (offset 24)<br>
         name @rpath/QtConcurrent.framework/Versions/5/QtConcurrent (offset 24)<br>
         name @rpath/QtWidgets.framework/Versions/5/QtWidgets (offset 24)<br>
         name @rpath/QtGui.framework/Versions/5/QtGui (offset 24)<br>
         name @rpath/QtCore.framework/Versions/5/QtCore (offset 24)<br>
         path /Users/Shared/EMsoft_SDK-ifort/EbsdLib-0.1-Release/lib (offset 12)<br>
         path /Users/Shared/EMsoft_SDK-ifort/Qt5.12.3/5.12.3/clang_64/lib (offset 12)<br>
<br>
<br>
Oddly the Qt libraries and one of my own libraries do get their rpaths encoded. I feel like I need to append to the RPATH that gets encoded into the executable but I am not really figuring out how to do that.<br>
<br>
Help....<br>
<br>
--<br>
Michael Jackson | Owner, President<br>
      BlueQuartz Software<br>
[e] <a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a><br>
[w] <a href="http://www.bluequartz.net" rel="noreferrer" target="_blank">www.bluequartz.net</a> <<a href="http://www.bluequartz.net" rel="noreferrer" target="_blank">http://www.bluequartz.net</a>><br>
<br>
<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>