Created
December 6, 2012 15:58
-
-
Save ohdarling/4225568 to your computer and use it in GitHub Desktop.
Fix library load path of Math-O file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Fix library load path | |
# Author: @ohdarling88 | |
# Thanks to http://stackoverflow.com/questions/4677044/how-to-use-dylib-in-mac-os-x-c#answer-11585225 | |
BIN=$1 | |
BINNAME=`basename $BIN` | |
DYLIBS=`otool -L $BIN | grep "/opt" | awk -F' ' '{ print $1 }'` | |
mkdir -p lib | |
for dylib in $DYLIBS; do | |
name=`basename $dylib` | |
if [ ! -f lib/$name ]; then | |
echo Copying $dylib ... | |
cp $dylib lib/ | |
fi | |
done | |
for dylib in $DYLIBS; do | |
name=`basename $dylib` | |
if [ "$BINNAME" != "$name" ]; then | |
install_name_tool -change $dylib @executable_path/lib/$name $BIN | |
fi | |
done | |
otool -L $BIN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment