<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>mikeash.com pyblog/friday-qa-2009-11-06-linking-and-install-names.html comments</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>mikeash.com Recent Comments</description><lastBuildDate>Mon, 17 Aug 2026 10:30:27 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Bruce - 2020-08-21 04:16:44</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>You can also use rpath to add @executable_path to the loading app.
&lt;br /&gt;
&lt;br /&gt;e.g. install_name_tool -add_rpath '@executable_path' myapp
&lt;br /&gt;
&lt;br /&gt;Best of both worlds.
&lt;br /&gt;</description><guid isPermaLink="true">264d81187ed54fb1d0751fa0517d6db9</guid><pubDate>Fri, 21 Aug 2020 04:16:44 GMT</pubDate></item><item><title>Ken - 2020-06-24 21:45:28</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>"I haven't found a way to discover what directories @rpath will expand to at runtime."
&lt;br /&gt;
&lt;br /&gt;Set the environmental variable DYLD_PRINT_LIBRARIES and launch the application.  It will print out exactly what it's loading.
&lt;br /&gt;
&lt;br /&gt;&lt;a href="https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/LoggingDynamicLoaderEvents.html"&gt;https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/LoggingDynamicLoaderEvents.html&lt;/a&gt;</description><guid isPermaLink="true">08d5196cd293323bbd886e1394344d3e</guid><pubDate>Wed, 24 Jun 2020 21:45:28 GMT</pubDate></item><item><title>Dhiren - 2014-07-03 09:10:19</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>Since with iOS 8, Dynamic Framework is allowed, Does above process is same for iOS Framework development??</description><guid isPermaLink="true">5116e9b6e5b57a2222ce19415a7d9b4a</guid><pubDate>Thu, 03 Jul 2014 09:10:19 GMT</pubDate></item><item><title>Jan Weiß - 2012-10-23 11:18:06</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>What Jerry described above didn’t work for me. I have written a wrapper for libzip (&lt;a href="http://nih.at/libzip/index.html"&gt;http://nih.at/libzip/index.html&lt;/a&gt;) called JXZip and it uses libzip’s included Xcode project to build a framework for it. 
&lt;br /&gt;
&lt;br /&gt;Now JXZip is built as a framework itself so it has to include “libzip Mac.framework”. It’s “Installation Directory” (INSTALL_PATH) is already set to @rpath. I do the usual “Build Phases” dance when building JXZip.framework: 
&lt;br /&gt;- Add the “libzip Mac” target to “Target Dependencies” 
&lt;br /&gt;- Add the build product to “Link Binary With Libraries” and “Copy Frameworks”
&lt;br /&gt;
&lt;br /&gt;As Jerry mentions above, the @loader_path is relative to the binary doing the loading. In this case it’s “JXZip”. For frameworks, the contained “Frameworks” is a subfolder of the folder where the binary is located. So we have to set “Runpath Search Paths” (LD_RUNPATH_SEARCH_PATHS) in the “Build Settings” to "@loader_path/Frameworks".</description><guid isPermaLink="true">2346f076b0df112e2e64c102664cea5f</guid><pubDate>Tue, 23 Oct 2012 11:18:06 GMT</pubDate></item><item><title>Jerry Krinock - 2012-08-20 19:08:29</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>In the section on @loader_path, Mike wrote that &lt;i&gt;If it's a framework or plugin, though, then it's relative to that framework or plugin&lt;/i&gt;.  More precisely, I've found that it's &lt;i&gt;relative to the loading executable in the framework or plugin&lt;/i&gt;. 
&lt;br /&gt;
&lt;br /&gt;This is important if a framework is expected to be loaded by another framework.  For example, when building the Sparkle framework into an app which accessed Sparkle via another framework, the app crashed upon launching outside of Xcode, because the Sparkle framework was not found, until I changed the Sparkle framework's Installation Directory from &lt;code&gt;@loader_path/../Frameworks&lt;/code&gt;, to &lt;code&gt;@loader_path/../../../../Frameworks&lt;/code&gt;.  In this case, the old fashioned &lt;code&gt;@executable_path/../Frameworks&lt;/code&gt; worked too (because the path starts at &lt;code&gt;Contents/MacOS/MyApp&lt;/code&gt;).  I decided that was a better choice.</description><guid isPermaLink="true">fc46cc41b5ae848fd2c7cedd74983179</guid><pubDate>Mon, 20 Aug 2012 19:08:29 GMT</pubDate></item><item><title>Konrad Windszus - 2010-05-26 20:32:49</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>Also check out MacDependency at &lt;a href="http://macdependency.googlecode.com"&gt;http://macdependency.googlecode.com&lt;/a&gt; which is a GUI replacement for otool and can also display used libraries with @rpath.</description><guid isPermaLink="true">f726dcaac97d93e397b72476db54849a</guid><pubDate>Wed, 26 May 2010 20:32:49 GMT</pubDate></item><item><title>Jay Tuley - 2009-11-22 16:23:59</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>Yeah, the wording in in the man page of the Dynamic Load Editor is a little odd, The framework Programing Guide: Installing Your Framework mentions this behavior too, but also pretends like &lt;code&gt;/Network/Library/Frameworks/&lt;/code&gt; isn't in that list, I've never tried that location personally though.
&lt;br /&gt;
&lt;br /&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html#//apple_ref/doc/uid/20002261-BBCCFBJA"&gt;http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html#//apple_ref/doc/uid/20002261-BBCCFBJA&lt;/a&gt;</description><guid isPermaLink="true">e5a8531c1b148096410c3345f8b84e82</guid><pubDate>Sun, 22 Nov 2009 16:23:59 GMT</pubDate></item><item><title>mikeash - 2009-11-22 03:01:10</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>I had no idea about this behavior. Looks like it comes from this bit in the man page:
&lt;br /&gt;
&lt;br /&gt;DYLD_FALLBACK_FRAMEWORK_PATH
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;This  is  a  colon  separated  list  of directories that contain
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;frameworks.  It is used as the default location  for  frameworks
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;not found in their install path.
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;By    default,    it   is   set   to   /Library/Frameworks:/Net-
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;work/Library/Frameworks:/System/Library/Frameworks
&lt;br /&gt;
&lt;br /&gt;This is really confusing wording because DYLD_FALLBACK_FRAMEWORK_PATH is not actually set on my system at all (yet the behavior works as you describe). I assume what they mean to say is that, if DYLD_FALLBACK_FRAMEWORK_PATH is not set, then the default is those paths.</description><guid isPermaLink="true">697916e31eb74a995c02bd319d5f8e37</guid><pubDate>Sun, 22 Nov 2009 03:01:10 GMT</pubDate></item><item><title>Jay Tuley - 2009-11-22 02:34:13</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>Thank you for your article, Rpath is really interesting and useful I had no idea it had been added.
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;I'd like to point out though a problem with your problem examples as that problem is a bit misleading
&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogcommentquote"&gt;&lt;div class="blogcommentquoteinner"&gt;
&lt;br /&gt;embedded in an application or when installed to /Library/Frameworks, you have to provide two separate copies with two different install names.
&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogcommentquote"&gt;&lt;div class="blogcommentquoteinner"&gt;
&lt;br /&gt;&amp;nbsp;If you want Foo.framework to work when embedded in an application or when installed to /Library/Frameworks, you have to provide two separate copies with two different install names. (Or manually tweak install names later on using install_name_tool.) This is doable, but annoying.
&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;These statements would be 100% correct with "~/Library/Frameworks", however not with "/Library/Frameworks" if you set a framework to any install path whatever it may be @executable, @loader, or just a random directory, if the framework does not exist where the install name says it should, by default Mac OS X will check 
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&lt;code&gt;
&lt;br /&gt;/Library/Frameworks 
&lt;br /&gt;/Network/Library/Frameworks 
&lt;br /&gt;/System/Library/Frameworks 
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;So if a framework is compiled with @executable_path or @loader_path it is still consumable by an app that wants to put in in any of the above 3 fallback directories (and luckily /Library/Frameworks is most likely and most common alternative). 
&lt;br /&gt;
&lt;br /&gt;Certainly rpath is more flexible and should be used when targeting only 10.5 or later, but for the common specific case of designing a framework to be used in a bundle or in /Library, frameworks targeting 10.4 using @loader_path aren't really as annoying as mentioned above.
&lt;br /&gt;</description><guid isPermaLink="true">0a8da6a6e71853ed6f96a0d58e77627f</guid><pubDate>Sun, 22 Nov 2009 02:34:13 GMT</pubDate></item><item><title>Jamie Hope - 2009-11-10 17:52:04</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>OK, thanks. It seems odd to me that there's nothing less clunky, but something like this works well enough:
&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogcommentquote"&gt;&lt;div class="blogcommentquoteinner"&gt;
&lt;br /&gt;#!/bin/bash
&lt;br /&gt;
&lt;br /&gt;for file in $@; do
&lt;br /&gt;&amp;nbsp;&amp;nbsp;echo "$file":
&lt;br /&gt;&amp;nbsp;&amp;nbsp;otool -l $file | grep -A 3 LC_RPATH | grep path
&lt;br /&gt;done
&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;</description><guid isPermaLink="true">87ea054b4839586412727dcfc94c79d2</guid><pubDate>Tue, 10 Nov 2009 17:52:04 GMT</pubDate></item><item><title>Ben - 2009-11-09 03:07:54</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>Mike,
&lt;br /&gt;Wanted to thank you for your series of Friday Q&amp;amp;A. It's hard to find deep OS and development topics covered in such detail for the Mac platform, and your blog is a precious resource.
&lt;br /&gt;
&lt;br /&gt;Thanks
&lt;br /&gt;Ben</description><guid isPermaLink="true">80b738e806c57686cbd0cfbbc3114953</guid><pubDate>Mon, 09 Nov 2009 03:07:54 GMT</pubDate></item><item><title>mikeash - 2009-11-09 01:56:48</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>I don't see a way to directly print only a binary's rpath list, but if you do &lt;code&gt;otool -l&lt;/code&gt; to list the binary's load commands, the rpaths will show up as &lt;code&gt;LC_RPATH&lt;/code&gt; commands.</description><guid isPermaLink="true">90eb5545bd1c7f778302fc0e6244ee82</guid><pubDate>Mon, 09 Nov 2009 01:56:48 GMT</pubDate></item><item><title>Jamie Hope - 2009-11-09 01:29:48</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>Thanks, Mike!
&lt;br /&gt;
&lt;br /&gt;Is there a way to examine a binary to see what list of rpath locations it was compiled with? On Leopard, I can use otool -L to see link entries of the form "@rpath/Foo.framework/Versions/A/Foo", but I haven't found a way to discover what directories @rpath will expand to at runtime.
&lt;br /&gt;
&lt;br /&gt;Since Brent has mentioned the Xcode way to use -rpath, I'll mention that if you invoke the linker through gcc (on the command line, or in a Makefile, etc) you have to use the "-Wl,option" gcc flag. So, "-rpath path" becomes "-Wl,-rpath,path".
&lt;br /&gt;
&lt;br /&gt;Also: if you're compiling a library and want the linker to look for a dependency in the same directory as the library, you have to do "-rpath @loader_path/.", not just "-rpath @loader_path". That one took me a little while to figure out.</description><guid isPermaLink="true">1c83ccad4a3a8e43f70d868695af84ee</guid><pubDate>Mon, 09 Nov 2009 01:29:48 GMT</pubDate></item><item><title>Brent Royal-Gordon - 2009-11-07 13:24:46</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>As it turns out, poking around this morning revealed a "Runtime Search Paths" option specifically for rpaths you want to add; using that instead of an -rpath option in Other Linker Flags allowed my program to use the embedded framework.
&lt;br /&gt;
&lt;br /&gt;Thanks for the explanation, Mike--this has had me blocked on a side project for a while!</description><guid isPermaLink="true">fc65e682121d77e3a7f0c171d8c2c01e</guid><pubDate>Sat, 07 Nov 2009 13:24:46 GMT</pubDate></item><item><title>mikeash - 2009-11-07 02:19:57</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>My intent is to just explain the theory. Other Linker Flags ought to work fine. If you're having specific problems with Xcode, I recommend Apple's xcode-users list.</description><guid isPermaLink="true">e6b44609a0405f6e03d67d0266799109</guid><pubDate>Sat, 07 Nov 2009 02:19:57 GMT</pubDate></item><item><title>Brent Royal-Gordon - 2009-11-07 01:53:33</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2009-11-06-linking-and-install-names.html#comments</link><description>This is great stuff, but do you think you can get it down to the concrete level of "here's where you put this setting in Xcode"?  In particular, where does the -rpath parameter go?  I tried using it in the "Other Linker Flags" build setting on my application's target, but the linker complains that it can't find the path.</description><guid isPermaLink="true">93a94b63d30f66fa099c6d88a5b41342</guid><pubDate>Sat, 07 Nov 2009 01:53:33 GMT</pubDate></item></channel></rss>
