Last active
December 27, 2015 17:09
-
-
Save Uflex/7359528 to your computer and use it in GitHub Desktop.
Sets all OpenCV dylibs to use absolute path (run after make install)
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 | |
# | |
# Fixes OpenCV to use absolute paths | |
# | |
# This script should be run ONLY ONCE, to make sure that the | |
# macdeployqt script will run properly (ie if it errors saying | |
# that a dylib could not be found) | |
# | |
set -u # exit if a parameter is missing | |
set -e # exit if an error occurs | |
LIB_DIR='/usr/local/lib/' # mandatory trailing / | |
LIB_NAME='libopencv' | |
OPENCV_VERSION='2.4.6' | |
cd ${LIB_DIR} | |
find . -type f -name "${LIB_NAME}*${OPENCV_VERSION}*.dylib" | while read file | |
do | |
file=$(basename $file) | |
# Fix the library id | |
install_name_tool -id ${LIB_DIR}${file} ${file} | |
# Fix the internal dependencies | |
otool -L ${file} | grep "${LIB_NAME}" | grep -v ':' | cut -d' ' -f1 | sed 's/^[[:space:]]*//g' | while read dylib | |
do | |
# get only the dylib name, removing the eventual path at the end | |
newName=$(echo ${dylib} | rev | cut -d'/' -f1 | rev) | |
newName="${LIB_DIR}${newName}" | |
install_name_tool -change ${dylib} ${newName} ${file} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment