Boost C++ Libraries: Ticket #1927: MacOS (Darwin) should use the -headerpad_max_install_name option https://svn.boost.org/trac10/ticket/1927 <p> Because of the way that dynamic linking works on MacOS, to be able to redistribute dynamic libraries it is necessary to include the path to the library in the executable. </p> <p> Attached is a patch (from the <a class="missing wiki">MacPorts</a> people) to make relocation much, much easier using MacOS's 'install_name_tool'. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1927 Trac 1.4.3 andrew@… Sat, 17 May 2008 16:19:41 GMT attachment set https://svn.boost.org/trac10/ticket/1927 https://svn.boost.org/trac10/ticket/1927 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">patch-tools-build-v2-tools-darwin.jam</span> </li> </ul> <p> add header padding to the dylib </p> Ticket Vladimir Prus Tue, 03 Jun 2008 16:32:21 GMT <link>https://svn.boost.org/trac10/ticket/1927#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1927#comment:1</guid> <description> <p> I cannot find any information about this option in google. Can you either point me at option's doc, and explanation why it's necessary, or describe it yourself? </p> <p> Thanks. </p> </description> <category>Ticket</category> </item> <item> <author>andrew@…</author> <pubDate>Tue, 03 Jun 2008 16:58:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1927#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1927#comment:2</guid> <description> <p> Sure - sorry, you couldn't google it because I was missing an 's' (the patch-file is fine, my bug summary missed the letter). </p> <p> From the Apple 'ld' linker man page: </p> <pre class="wiki"> -headerpad_max_install_names (32-bit only) Add to the header padding enough space to allow changing all dynamic shared library paths recorded in the output file to be changed to MAXPATHLEN in length. </pre><p> (The option is not needed for 64-bit objects, and is silently ignored.) </p> <p> Basically, when creating shared objects, the apple linker places a semi-absolute pathname of the library and all dependent dynamic objects into the object. Think of it as the apple 'solution' to Linux's ld.so conf file. To see the paths of embedded objects, use "otool -L". To <strong>change</strong> the embedded path name, use "install_name_tool". </p> <p> It is the changing-part that needs the header padding. Suppose I build boost and install it into /opt/local. Then all the libraries reference themselves (and any other required libs) as '/opt/local/lib/libboost-blah.dyld'. If I want to redistribute my software binaries plus libraries, I need to rename the internal name of the libraries. </p> <p> Without the headerpad option to the linker, the new path must be equal or shorter in length than the old path. Blech! With the headerpad option, I can use any valid filesystem path. </p> <p> Thus, building redistributable binaries in boost is only practical on darwin with this option. </p> <p> Yes, it is a kludge... and that's why apple fixed it for the 64-bit sub-file-format. </p> <p> Cheers, -Andrew. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Vladimir Prus</dc:creator> <pubDate>Tue, 03 Jun 2008 17:14:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1927#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1927#comment:3</guid> <description> <p> Do you mean that on OSX, it is the standard practice to embed full path to dependency libraries into shipped applications? Is each application supposed to be installed into a fixed location? </p> </description> <category>Ticket</category> </item> <item> <author>andrew@…</author> <pubDate>Tue, 03 Jun 2008 17:30:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1927#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1927#comment:4</guid> <description> <p> The short, but inaccurate answer, is "yes". </p> <p> Dynamic library paths and linking on Apple is <strong>not</strong> as simple topic. Libraries (inside frameworks) are usually in fixed locations. There is (under 10.4) a "magic" file name so libraries can be located with respect to the executable file bundle. </p> <p> Apple has <a class="ext-link" href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachOTopics/Articles/loading_code.html"><span class="icon">​</span>extensive documentation</a> on how dyld files are searched for. </p> <p> A brief (and informative) summary is <a class="ext-link" href="http://qin.laya.com/tech_coding_help/dylib_linking.html"><span class="icon">​</span>here</a>. </p> <p> Leopard (10.5) introduced RPATH semantics <a class="ext-link" href="http://www.codeshorts.ca/2007/nov/01/leopard-linking-making-relocatable-libraries-movin"><span class="icon">​</span>see here</a>. </p> <p> But basically... using the "-headerpad_max_install_names" linker option allows the boost user to compile boost <strong>once</strong> and then package up the libraries as "application-specific framework bundles" in a final application. Without the headerpad option, boost must be custom-compiled to its final installation directory for every project that uses it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>René Rivera</dc:creator> <pubDate>Tue, 24 Jun 2008 16:03:10 GMT</pubDate> <title>status, component, milestone changed; owner set https://svn.boost.org/trac10/ticket/1927#comment:5 https://svn.boost.org/trac10/ticket/1927#comment:5 <ul> <li><strong>owner</strong> set to <span class="trac-author">René Rivera</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">Building Boost</span> → <span class="trac-field-new">build</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.35.1</span> → <span class="trac-field-new">Boost 1.36.0</span> </li> </ul> Ticket andrew@… Tue, 24 Jun 2008 16:13:07 GMT <link>https://svn.boost.org/trac10/ticket/1927#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1927#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1927#comment:5" title="Comment 5">grafik</a>: Sorry - forgot to mention this earlier - but the attached patch has been part of the <a class="missing wiki">MacPorts</a> build system for a while, so a fair number of people have been using/compiling with it already. I just didn't want you to think that it was totally untried... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>René Rivera</dc:creator> <pubDate>Fri, 27 Jun 2008 21:15:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1927#comment:7 https://svn.boost.org/trac10/ticket/1927#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed in rev <a class="changeset" href="https://svn.boost.org/trac10/changeset/46793" title="Cleanup of darwin/xcode toolset. Now much more sensible support for ...">[46793]</a>, along with other cleanups. </p> Ticket