Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 5, 2013, 10:48 AM   #1
printz
macrumors regular
 
Join Date: Dec 2012
Change a binary's dependency paths?

I know that with 'otool -L' I can list a binary file's libraries it depends on. Is there a way to change its library search paths? I know I can already change a library's install name with install_name_tool. Can I do the same with the library search paths?
printz is offline   0 Reply With Quote
Old Aug 5, 2013, 01:45 PM   #2
ElectricSheep
macrumors 6502
 
Join Date: Feb 2004
Location: Wilmington, DE
Send a message via AIM to ElectricSheep
You can export colon-separated lists of paths to DYLD_FRAMEWORK_PATH and/or DYLD_LIBRARY_PATH environment variables to specify what directories should be searched first for Frameworks and Libraries. This allows you to test new versions of frameworks and libraries without having to install them to the standard search paths.
__________________
15'' MBP (early 2011) | i7 3770k Hackintosh | i7 Mac Mini (late 2012) | iPhone 5 | iPad 3 (2012) | iPad mini | MacOS X 10.9.2
ElectricSheep is offline   0 Reply With Quote
Old Aug 6, 2013, 04:29 AM   #3
printz
Thread Starter
macrumors regular
 
Join Date: Dec 2012
Yeah but I want to change an alreadily built binary's search paths. Like for example it depends on some dylibs located in /opt/local/bin/. I want it to depend on those same files, but located in @loader_path/.
printz is offline   0 Reply With Quote
Old Aug 6, 2013, 07:18 AM   #4
ElectricSheep
macrumors 6502
 
Join Date: Feb 2004
Location: Wilmington, DE
Send a message via AIM to ElectricSheep
And that is what those environment variables can allow you to do. For example, I have a version of python built via MacPorts which is staged in /opt/local/. Normally, it will search for Frameworks and dylibs in /opt/local/Library/Frameworks/ and /opt/local/lib to bind at runtime.

Setting the environment variable DYLD_PRINT_LIBRARIES causes dyld to print a dump of all the frameworks and libraries bound at runtime to verify what is actually being loaded from where. Normally, my MacPorts python would load ncurses from /opt/local/lib/libncurses.5.dylib. If I setenv DYLD_LIBRARY_PATH /usr/lib/ and execute my MacPorts python again, it loads ncurses from /usr/lib/libncurses.5.4.dylib.

See the manpage for dyld for more environment variables that you can use to manipulate how dylibs and frameworks are loaded at runtime.
__________________
15'' MBP (early 2011) | i7 3770k Hackintosh | i7 Mac Mini (late 2012) | iPhone 5 | iPad 3 (2012) | iPad mini | MacOS X 10.9.2
ElectricSheep is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Apple Mobile Device Services - TCP/IP protocol driver dependency issue spiegel9 iPhone Tips, Help and Troubleshooting 2 May 22, 2013 04:01 AM
iPhone: Cydia: Error Couldn’t configure pre-depend dpkg for ncurses, probably a dependency cy eelinnah Jailbreaks and iOS Hacks 7 Apr 5, 2013 11:29 AM
Header Search Paths ahan.tm iPhone/iPad Programming 1 Jan 28, 2013 06:34 AM
Obama: only two paths for 'taxes' IBradMac Politics, Religion, Social Issues 161 Dec 19, 2012 11:46 PM
Multiple Index Paths luke3 iPhone/iPad Programming 1 Jul 6, 2012 10:08 PM

Forum Jump

All times are GMT -5. The time now is 01:05 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC