Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running applications against a different SDK in OS X?

Summary

I want to run my cross-compiled application against the 10.5 libraries. Is there an environmental variable that allows this to work?

Longer version

I cross-compiled my OS X C++ application for a 10.5 target, on a 10.6 host. It compiles fine. The compiled application is linked against libraries like /usr/lib/libstdc++.6.dylib. When I run it on my system, it will use the 'host' version of libraries, which are 10.6. I'd like to test it against the 10.5 versions, which are all contained in the `/Developer/SDKs/MacOSX10.5.sdk directory. How do I do this?

I tried various flavours of DYLD_LIBRARY_PATH, DYLD_ROOT_PATH, etc, as documented in the manual, but I haven't managed to get it working.

like image 744
Paul Biggar Avatar asked Oct 04 '10 14:10

Paul Biggar


1 Answers

Use install_name_tool to change the path. You may not be able to squeeze in a longer path if the linker didn't add padding, but you can use an rpath instead. For example, I changing the load path for an app on my system to use the 10.5 SDK by doing:

install_name_tool -change /usr/lib/libstdc++.6.dylib @rpath/libstdc++.6.dylib /path/to/executable
install_name_tool -add_rpath /Developer/SDKs/MacOSX10.5.sdk/usr/lib /path/to/executable

and it ran fine after the fact. I wouldn't want to make any assurances, but assuming you compiled against the 10.5 SDK initially, you've got a shot.

If you need to see the paths the executable is using, otool -L will list them.

like image 163
Kirk Kelsey Avatar answered Sep 17 '22 02:09

Kirk Kelsey