[Solved]install_name_tool of mac can't change the id
-
I need to let the app know where to find the 3rd party dylib
Study a lot of data but still don't get itWith the help of otool
@otool -L imageInterpolation.app/Contents/MacOS/imageInterpolation@otool give me the following message of the 3rd party dylib
@lib/libopencv_core.2.4.dylib (compatibility version 2.4.0, current version 2.4.3)@
I suppose this is the original id of the dylib?To tell the app how to link to the dylib
First, create a folder inside the appchange the id of the dylib by the install_name_tool
@install_name_tool -id @executable_path/../Frameworks/libopencv_core.2.4.3.dylib lib/libopencv_core.2.4.dylib@
But this would pop out error message
install_name_tool: can't open file: lib/libopencv_core.2.4.3.dylib (No such file or directory)
To solve the problems, I copy the dylib "libopencv_core.2.4.3.dylib" to "/lib"
and change the name to "libopencv_core.2.4.dylib"Run the command
@install_name_tool -id @executable_path/../Frameworks/libopencv_core.2.4.3.dylib /lib/libopencv_core.2.4.dylib"@This time, no error or warning, but the id remain the same
That is, When I run the otool@otool -L imageInterpolation.app/Contents/MacOS/imageInterpolation@
The result is
@lib/libopencv_core.2.4.dylib (compatibility version 2.4.0, current version 2.4.3)@ -
I change the command
@
cp /usr/local/lib/libopencv_core.2.4.3.dylib /Users/Qt/program/commercial_apps/imageInterpolation/imageInterpolation.app/Contents/Frameworksinstall_name_tool -id @executable_path/../Frameworks/libopencv_core.2.4.3.dylib \ /Users/Qt/program/commercial_apps/imageInterpolation/imageInterpolation.app/Contents/Frameworks/libopencv_core.2.4.3.dylib
@But the id remain the same, nothing change
This time I didn't use the option of -change because
I don't know how to use it -
I solved it, thanks to the link
"solution":http://www.dafscollaborative.org/opencv-deploy.htmlmy script
@
#!/bin/bashmkdir imageInterpolation.app/Contents/Frameworks
cp /Users/Qt/program/commercial_apps/imageInterpolation/release/libimageViewer.1.0.0.dylib /Users/Qt/program/commercial_apps/imageInterpolation/imageInterpolation.app/Contents/Frameworks
mv /Users/Qt/program/commercial_apps/imageInterpolation/imageInterpolation.app/Contents/Frameworks/libimageViewer.1.0.0.dylib
/Users/Qt/program/commercial_apps/imageInterpolation/imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylibsource ~/.mybash_profile #macdeployqt path
macdeployqt /Users/Qt/program/commercial_apps/imageInterpolation/imageInterpolation.app -verbose=2 -dmg
#openCV libraries***********
#update openCV id*******#
install_name_tool -id @executable_path/../Frameworks/libopencv_core.2.4.dylib imageInterpolation.app/Contents/Frameworks/libopencv_core.2.4.dylib
install_name_tool -id @executable_path/../Frameworks/libopencv_highgui.2.4.dylib imageInterpolation.app/Contents/Frameworks/libopencv_highgui.2.4.dylib
install_name_tool -id @executable_path/../Frameworks/libopencv_imgproc.2.4.dylib imageInterpolation.app/Contents/Frameworks/libopencv_imgproc.2.4.dylib
#install_name_tool -id @executable_path/../Frameworks/libopencv_photo.2.4.dylib imageInterpolation.app/Contents/Frameworks/libopencv_photo.2.4.dylib#change openCV libraries references*******#
install_name_tool -change lib/libopencv_core.2.4.dylib @executable_path/../Frameworks/libopencv_core.2.4.dylib "imageInterpolation.app/Contents/MacOS/imageInterpolation"
install_name_tool -change lib/libopencv_highgui.2.4.dylib @executable_path/../Frameworks/libopencv_highgui.2.4.dylib "imageInterpolation.app/Contents/MacOS/imageInterpolation"
install_name_tool -change lib/libopencv_imgproc.2.4.dylib @executable_path/../Frameworks/libopencv_imgproc.2.4.dylib "imageInterpolation.app/Contents/MacOS/imageInterpolation"
install_name_tool -change lib/libopencv_photo.2.4.dylib @executable_path/../Frameworks/libopencv_photo.2.4.dylib "imageInterpolation.app/Contents/MacOS/imageInterpolation"#change openCV internal libraries cross-references*******#
install_name_tool -change lib/libopencv_core.2.4.dylib @executable_path/../Frameworks/libopencv_core.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libopencv_highgui.2.4.dylib"
install_name_tool -change lib/libopencv_imgproc.2.4.dylib @executable_path/../Frameworks/libopencv_imgproc.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libopencv_highgui.2.4.dylib"install_name_tool -change lib/libopencv_core.2.4.dylib @executable_path/../Frameworks/libopencv_core.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libopencv_imgproc.2.4.dylib"
install_name_tool -change lib/libopencv_core.2.4.dylib @executable_path/../Frameworks/libopencv_core.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libopencv_photo.2.4.dylib"
install_name_tool -change lib/libopencv_imgproc.2.4.dylib @executable_path/../Frameworks/libopencv_imgproc.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libopencv_photo.2.4.dylib"#******self created library sc = self created
#update sc id*******#
install_name_tool -id @executable_path/../Frameworks/libimageViewer.1.dylib imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib
#change sc libraries references*******#
install_name_tool -change libimageViewer.1.dylib @executable_path/../Frameworks/libimageViewer.1.dylib "imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"
#change sc internal libraries cross-references*******#
install_name_tool -change lib/libopencv_core.2.4.dylib @executable_path/../Frameworks/libopencv_core.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"
install_name_tool -change lib/libopencv_highgui.2.4.dylib @executable_path/../Frameworks/libopencv_highgui.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"
install_name_tool -change lib/libopencv_imgproc.2.4.dylib @executable_path/../Frameworks/libopencv_imgproc.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"
install_name_tool -change lib/libopencv_photo.2.4.dylib @executable_path/../Frameworks/libopencv_photo.2.4.dylib "imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"install_name_tool -change /Users/yyyy/Qt5.0.1/5.0.1/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets
@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets
"imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"install_name_tool -change /Users/yyyy/Qt5.0.1/5.0.1/clang_64/lib/QtGui.framework/Versions/5/QtGui
@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui
"imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"install_name_tool -change /Users/yyyy/Qt5.0.1/5.0.1/clang_64/lib/QtCore.framework/Versions/5/QtCore
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore
"imageInterpolation.app/Contents/Frameworks/libimageViewer.1.dylib"exit 0
@Whatever, this solution is hack, deploy third parties or self created dylib on mac
is very inconvenient -
I know it's old post but I had troubles with qt + mac + opencv deploy
Here is final version of simple bruteforce script:
http://pastebin.com/uwr0z9YY