Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create link_bin.sh #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions archive/link_bin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# Notes ( http://clarkkromenaker.com/post/library-dynamic-loading-mac/ )

myArray=("luna" "destrat" "behead" "fixrows")

rm -rf ../mac-arm-luna
mkdir ../mac-arm-luna
cd ../mac-arm-luna

fftw_lib='/opt/homebrew/opt/fftw/lib/libfftw3.3.dylib'
omp_lib='/opt/homebrew/opt/libomp/lib/libomp.dylib'

cp $fftw_lib .
cp $omp_lib .
cp ../luna .
cp ../destrat .
cp ../behead .
cp ../fixrows .

for str in ${myArray[@]}; do

# Fixing LC_LOAD_DYLIB entries (change dynamic library loader path)
# Please check the field LC_LOAD_DYLIB in "otool -l luna" output
install_name_tool -change $fftw_lib @rpath/libfftw3.3.dylib ./$str
install_name_tool -change $omp_lib @rpath/libomp.dylib ./$str

# Instructs the loader to search a list of paths to find the dynamic library
# Please check the field LC_RPATH in "otool -l luna" output
# Because I used @rpath in the earlier step, the executable must specify a list of search path in LC_RPATH
install_name_tool -add_rpath @executable_path/. ./$str

done

# Prints paths to all dynamic libraries used by the executable
otool -L ./luna
otool -L ./destrat
echo

# To view what libraries an executable in loading
DYLD_PRINT_LIBRARIES=1 ./luna

echo
echo "Please check the newly created directory named ../mac-arm-luna"