Making a framework relocatable.

Sage
Posts: 1,482
Joined: 2002.09
Post: #1
I compiled the vorbis extension for OpenAL, very handy. The only problem is that the Ogg and Vorbis frameworks think that they have to be installed in /Library/Frameworks. This is slightly confusing as the frameworks weren't even there when I linked against them.

What do I need to do to make them bundle-able?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
the frameworks themselves are bundlable already, it's the executable that's at fault. There are two ways to fix the problem :-

a) build the frameworks passing -install_name @executable_path/../Frameworks to the linker, then relink your application
b) build your application with -headerpad_max_install_names, then use install_name_tool -change /Library/Frameworks/Foo.framework/Versions/A/Foo @executable_path/../Frameworks/Foo.framework/Versions/A/Foo . You can use otool -L on the binary to find out what the "from" path should be, and to verify that your change has taken effect.
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #3
OneSadCookie Wrote:b) build your application with -headerpad_max_install_names, then use install_name_tool -change /Library/Frameworks/Foo.framework/Versions/A/Foo @executable_path/../Frameworks/Foo.framework/Versions/A/Foo . You can use otool -L on the binary to find out what the "from" path should be, and to verify that your change has taken effect.

I thought the frameworks had to be built this way for it to work.. but if not, that's awesome! I guess I'm thinking of people building frameworks with the max install name space, and then changing them later (instead of the executable itself). Thanks for the tip.

I guess you still have to build the frameworks yourself if they depend on more bundles frameworks though.

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
OneSadCookie Wrote:the frameworks themselves are bundlable already, it's the executable that's at fault. There are two ways to fix the problem :-

a) build the frameworks passing -install_name @executable_path/../Frameworks to the linker, then relink your application

Will that make it so that it can only be bundled though?

Let me see if I have this right.
The framework must have an intended set of search paths included when built. If it's not in one of those places, then you have to specifically tell the linker where to find it.

Don't suppose you have a link that would explain how all of this works with frameworks and dylibs. Specifically how the dynamic linker goes about finding the right library and what compile-time options affect this. I'm not really sure what to Google for, so my searching has been pretty barren.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
On Mac OS X, the location to search for the framework is hard-coded into the application. otool -L shows you what has been hard-coded in. If the framework is not found at that location, then /Library/Frameworks and /System/Library/Frameworks will be searched for a framework of the same name.

The path that is hard-coded into the application is the framework's install_name, and it is copied from the framework at link time. The actual location of the framework that's linked against is irrelevant, only the path hardcoded into that framework. That can be set with the -install_name option to the linker when creating the framework.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #6
~/Library/Frameworks is also searched.

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
wrong.

/Network/Library/Frameworks is searched, though.

man dyld
Quote this message in a reply
Draykan
Unregistered
 
Post: #8
Skorche Wrote:Don't suppose you have a link that would explain how all of this works with frameworks and dylibs. Specifically how the dynamic linker goes about finding the right library and what compile-time options affect this. I'm not really sure what to Google for, so my searching has been pretty barren.

If you are interested in dynamic library programming topics this a link to official Apple documentation on the topic: Dynamic Library Programming Topics.
Quote this message in a reply
Post Reply