Skip to content

Commit

Permalink
fix: mac change rpath to loader_path
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Nov 7, 2024
1 parent 9c2d338 commit 3adce42
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tools/fix_mac_rpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,32 @@ libcxx_path=`otool -L $install_dir/bin/libMaaFramework.dylib | grep libc++ | awk

echo "libc++.1.dylib: $libcxx_path"

if [[ "$libcxx_path" == "@rpath/libc++.1.dylib" ]]; then
echo "already linked to @rpath/libc++, quit"
if [[ "$libcxx_path" == "@loader_path/libc++.1.dylib" ]]; then
echo "already linked to @loader_path/libc++, quit"
exit 0
fi

echo "change $libcxx_path to @rpath/libc++.1.dylib"
echo "change $libcxx_path to @loader_path/libc++.1.dylib"

for lib in libc++ libc++abi libunwind; do
rm $install_dir/bin/$lib.1.dylib
rm $install_dir/bin/$lib.dylib
mv $install_dir/bin/$lib.1.0.dylib $install_dir/bin/$lib.1.dylib

bin=$install_dir/bin/$lib.1.dylib
echo "processing $bin"
if otool -L $bin | grep @rpath/libc++.1 > /dev/null; then
install_name_tool -change @rpath/libc++.1.dylib @loader_path/libc++.1.dylib $bin
fi
if otool -L $bin | grep @rpath/libc++abi.1 > /dev/null; then
install_name_tool -change @rpath/libc++abi.1.dylib @loader_path/libc++abi.1.dylib $bin
fi
if otool -L $bin | grep @rpath/libunwind.1 > /dev/null; then
install_name_tool -change @rpath/libunwind.1.dylib @loader_path/libunwind.1.dylib $bin
fi
done

for bin in $install_dir/bin/*; do
echo "processing $bin"
install_name_tool -change $libcxx_path "@rpath/libc++.1.dylib" $bin
install_name_tool -change $libcxx_path "@loader_path/libc++.1.dylib" $bin
done

0 comments on commit 3adce42

Please sign in to comment.