From bc7772e3413df4a0f7ba4074de066d46fe22fd71 Mon Sep 17 00:00:00 2001 From: Senthil Palanivelu Date: Fri, 14 Apr 2023 13:47:04 -0400 Subject: [PATCH 1/3] Create link_bin.sh --- archive/link_bin.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 archive/link_bin.sh diff --git a/archive/link_bin.sh b/archive/link_bin.sh new file mode 100644 index 00000000..47128d0a --- /dev/null +++ b/archive/link_bin.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +myArray=("luna" "destrat" "behead" "fixrows") + +mkdir ../mac-arm-luna +cd ../mac-arm-luna + +cp /opt/homebrew/opt/fftw/lib/libfftw3.3.dylib . +cp /opt/homebrew/opt/libomp/lib/libomp.dylib . +cp ../luna . +cp ../destrat . +cp ../behead . +cp ../fixrows . + +for str in ${myArray[@]}; do + install_name_tool -add_rpath @executable_path/. ./$str + install_name_tool -change /opt/homebrew/opt/fftw/lib/libfftw3.3.dylib @rpath/libfftw3.3.dylib ./$str + install_name_tool -change /opt/homebrew/opt/libomp/lib/libomp.dylib @rpath/libomp.dylib ./$str +done + +otool -L ./luna +otool -L ./destrat + +echo +echo "Please check the newly created directory named ../mac-arm-luna" From 5f66a88924a328903662c9cf00d52eab000eb363 Mon Sep 17 00:00:00 2001 From: Senthil Palanivelu Date: Sat, 15 Apr 2023 11:15:27 -0400 Subject: [PATCH 2/3] Update link_bin.sh --- archive/link_bin.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/archive/link_bin.sh b/archive/link_bin.sh index 47128d0a..2000bf9e 100644 --- a/archive/link_bin.sh +++ b/archive/link_bin.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Notes ( http://clarkkromenaker.com/post/library-dynamic-loading-mac/ ) + myArray=("luna" "destrat" "behead" "fixrows") mkdir ../mac-arm-luna @@ -13,11 +15,19 @@ cp ../behead . cp ../fixrows . for str in ${myArray[@]}; do + + # 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 install_name_tool -add_rpath @executable_path/. ./$str + + # Change dynamic library loader path + # Please check the field LC_LOAD_DYLIB in "otool -l luna" output install_name_tool -change /opt/homebrew/opt/fftw/lib/libfftw3.3.dylib @rpath/libfftw3.3.dylib ./$str install_name_tool -change /opt/homebrew/opt/libomp/lib/libomp.dylib @rpath/libomp.dylib ./$str + done +# Prints paths to all dynamic libraries used by the executable otool -L ./luna otool -L ./destrat From ef88bc47520b4b6a991cb4f3c67ee6bf73153d4b Mon Sep 17 00:00:00 2001 From: Senthil Palanivelu Date: Mon, 17 Apr 2023 10:18:14 -0400 Subject: [PATCH 3/3] Update link_bin.sh --- archive/link_bin.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/archive/link_bin.sh b/archive/link_bin.sh index 2000bf9e..d7f8635a 100644 --- a/archive/link_bin.sh +++ b/archive/link_bin.sh @@ -1,35 +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 -cp /opt/homebrew/opt/fftw/lib/libfftw3.3.dylib . -cp /opt/homebrew/opt/libomp/lib/libomp.dylib . +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 - # Change dynamic library loader path - # Please check the field LC_LOAD_DYLIB in "otool -l luna" output - install_name_tool -change /opt/homebrew/opt/fftw/lib/libfftw3.3.dylib @rpath/libfftw3.3.dylib ./$str - install_name_tool -change /opt/homebrew/opt/libomp/lib/libomp.dylib @rpath/libomp.dylib ./$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"