Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funkym/install_name_prefix_tool
Shell script for Mac OS X which changes the library prefix for a series of shared libraries in a folder or a single executable.
https://github.com/funkym/install_name_prefix_tool
linking macos otool shared-libraries shell
Last synced: 8 days ago
JSON representation
Shell script for Mac OS X which changes the library prefix for a series of shared libraries in a folder or a single executable.
- Host: GitHub
- URL: https://github.com/funkym/install_name_prefix_tool
- Owner: FunkyM
- License: apache-2.0
- Created: 2013-05-30T22:54:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-14T06:08:00.000Z (over 11 years ago)
- Last Synced: 2023-03-28T00:00:27.790Z (over 1 year ago)
- Topics: linking, macos, otool, shared-libraries, shell
- Language: Shell
- Homepage:
- Size: 117 KB
- Stars: 16
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
install_name\_prefix\_tool
========================Shell script for Mac OS X which changes the library prefix for a series of shared libraries in a folder or a single executable.
Overview
--------This is a simple bash script which processes a series of Mac OS X shared libraries (.dylib) in a directory and uses [install\_name\_tool](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html) to modify the binary library link names.
The use-case for this script is usually to modify a series of existing shared libraries or an executable for loading from a relative location.
Example
-------Say you have a couple of libraries which dependent upon each other and installed them in a directory "/usr/local/lib/".
Now you want to package these libraries with your main application. If you check each libraries link dependencies using "otool -L [LIBRARY_FILE]", you'll notice they point to "/usr/local/lib/".
Using this script, you can now modify all of the library links at once for instance to some local folder next to the main binary. If you copy all libraries to a "lib/" folder next to your main application binary, you can run the following command to make all shared libraries load and reside in "lib/".
$ install_name_prefix_tool.sh ./lib /usr/local/lib @executable_path/lib
Finally you must also modify the loader path for your application to pick up the shared libraries from the relative "lib/" folder.
$ install_name_prefix_tool.sh ./myapplication /usr/local/lib @executable_path/libIf you now verify the links using otool again, you'll notice that it now uses the new prefix to lookup dependent libraries which will be relative to your main executable due to the special token "@executable_path".
Handy, ain't it?