Running applications against another SDK on OS X?

Summary

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

Longer version

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

I tried various options of DYLD_LIBRARY_PATH, DYLD_ROOT_PATH, etc., as documented in the manual , but I was not able to get it to work.

+6
c ++ libraries linker loader macos
source share
3 answers

Use change_name_tool to change the path. You may not be able to compress the long path if the linker has not added the add-on, but you can use rpath instead. For example, I change the download path for an application 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 after that he did a great job. I would not want to make any assurances, but assuming you are compiled against the 10.5 SDK, you have a chance.

If you need to see the paths that the executable uses, otool -L display them.

+3
source share

This is unlikely, given that OS X does not have a stable ABI kernel. Instead, a stable ABI is one that is provided by system libraries. Therefore, the use of system libraries of a different version than the kernel may be violated. (I don't know the extent to which it breaks.)

See http://developer.apple.com/library/mac/#qa/qa2001/qa1118.html

0
source share

Try the following:

  • Open the project in Xcode.
  • In the "Executable files in the group and files" column, right-click the application executable file and select "Get Information"
  • Select the Arguments tab
  • In the lower half of the window, in the "Variables that should be set in the environment:" section, click the "+" button.
  • In the row displayed in the table, enter DYLD_LIBRARY_PATH in the Name field and enter the path (for example, / Developer / SDKs / MacOSX10.5.sdk / usr / lib) in the Value section.

You have now set up the link path environment variable. This environment variable will be set for you when you run this executable from Xcode. To test the application, just go to the Run menu and select Run. If you launch the application by double-clicking it directly in Finder, you will not get this environment variable set for you. This option takes effect only when Xcode starts.

Here's the Apple documentation for this process:

http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/XcodeProjectManagement/230-Defining_Executable_Environments/executable_environments.html

-one
source share

All Articles