<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>When using @rpath, the proper way to the executable to find it at runtime is for the executable to have an rpath with a directory that contains the dylib.</div><div><br></div><div>When compiling the executable, the linker flag "-rpath /path/to/dylib" should be given.  This should be automatic with CMake when building the executable, and if it isn't doing that for you, please give us an example.</div><div>To verify, the executable has the rpath, you can run "otool -l <executable> | grep LC_RPATH -A2"</div><div><br></div><div><span style="font-size: 12pt;">Clint</span></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div dir="ltr">So I noticed the CMAKE_MACOSX_RPATH variable, and tried setting it, which does result in the install name of the dylib being set to @rpath/dylibname.so BUT when I link it in an executable tool -L just shows the dylib as @rpath/dylibname.so and the linker fails to find it at run time. What is the proper way to get CMake to build the executable linking against the dylib and be able to run it in the build tree and install tree?</div><div class="gmail_extra"><br clear="all"><div>Izaak Beekman<br>===================================<br>(301)244-9367<br>UMD-CP Visiting Graduate Student<br>Aerospace Engineering<br><a href="mailto:ibeekman@umiacs.umd.edu" target="_blank" data-mce-href="mailto:ibeekman@umiacs.umd.edu">ibeekman@umiacs.umd.edu</a><br> <a href="mailto:ibeekman@umd.edu" target="_blank" data-mce-href="mailto:ibeekman@umd.edu">ibeekman@umd.edu</a></div><br><div><br></div><div class="gmail_quote">On Sat, May 3, 2014 at 10:54 AM, Dan Kegel <span dir="ltr"><<a href="mailto:dank@kegel.com" target="_blank" data-mce-href="mailto:dank@kegel.com">dank@kegel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div class="">On Sat, May 3, 2014 at 7:17 AM,  <<a href="mailto:clinton@elemtech.com" target="_blank" data-mce-href="mailto:clinton@elemtech.com">clinton@elemtech.com</a>> wrote:<br> > Use at least CMake 2.8.12 and in your library project add this:<br> > set(CMAKE_MACOSX_RPATH 1)<br></div>> ...<br><div class="">> For more details:<br> > <a href="http://www.kitware.com/blog/home/post/510" target="_blank" data-mce-href="http://www.kitware.com/blog/home/post/510">http://www.kitware.com/blog/home/post/510</a><br> <br></div>What he said.  See also past discussion at<br> <a href="http://web.archiveorange.com/archive/v/5y7PkspCBZwiWhvodZSP" target="_blank" data-mce-href="http://web.archiveorange.com/archive/v/5y7PkspCBZwiWhvodZSP">http://web.archiveorange.com/archive/v/5y7PkspCBZwiWhvodZSP</a><br> I put together some tiny demos showing various ways to do it, with<br> walkthroughs, at<br> <a href="http://kegel.com/macosx/rpath/" target="_blank" data-mce-href="http://kegel.com/macosx/rpath/">http://kegel.com/macosx/rpath/</a><br></blockquote></div><br></div></blockquote><div><br></div></div></body></html>