install-name-tool通过otool查看时不会添加库路径? [英] install-name-tool does not add path to library when viewed through otool?
问题描述
我使用Xcode和Qt完成了我的Mac应用程序。现在我想准备部署到其他macs。为了这样做,我使用macdeployqt。
我刚刚创建了一个应用程序包macdeployqt。但是有些库缺少。我试图遵循[这个] [1]的回答。结果我需要将丢失的dylib从我的电脑复制到.app然后运行安装名称工具。我还没有得到安装名工具,因为我很困惑使用 -id
或 -change
与它特别是在我目前的情况。我甚至需要使用它吗?这里是我做了到目前为止。
步骤1:运行macdeployqt - 这是一个带有Qt的程序,并将qt的必要要求嵌入到应用程序中。
> /Users/Guest/Qt/5.5/clang_64/bin/macdeployqt project2.app
步骤2:I然后决定对实际生成的应用程序二进制文件运行otool
> pwd
/Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS
> otool -L project2
project2:
@ rpath / libcreatecore_rt.dylib(兼容性版本0.0.0,当前版本0.0.0)
@ rpath / QtQuick.framework /版本/ 5 / QtQuick(兼容性版本5.5.0,当前版本5.5.1)
@ rpath / QtConcurrent.framework / Versions / 5 / QtConcurrent(兼容性版本5.5.0,当前版本5.5.1)
@ rpath / QtSvg.framework / Versions / 5 / QtSvg(兼容性版本5.5.0,当前版本5.5.1)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL(兼容性版本1.0.0 ,当前版本1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL(兼容性版本1.0.0,当前版本1.0.0)
@executable_path /../框架/ libosg.141.dylib(兼容性版本141.0.0,当前版本3.5.1)
@executable_path /../ Frameworks / libosgDB.141.dylib(兼容性版本141.0.0,当前版本3.5.1)
@executable_path /../ Frameworks / libosgGA.141.dylib(兼容版本141.0.0,当前版本3.5.1)
@executable_path /../ Frameworks / libosgUtil.141.dylib(兼容版本141.0.0,当前版本3.5.1)
@executable_path /../ Frameworks / libosgViewer.141.dylib(兼容版本141.0.0,当前版本3.5.1)
@executable_path /../框架/ libosgManipulator.141.dylib(兼容版本141.0.0,当前版本3.5.1)
@executable_path /../ Frameworks / libOpenThreads.20.dylib(兼容版本20.0.0,当前版本3.3.0)
/usr/lib/libz.1.dylib(兼容性版本1.0.0,当前版本1.2.5)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa(兼容性版本1.0.0,当前版本22.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation(兼容性版本150.0.0,当前版本1256.14.0)
/ usr / lib / libiconv.2.dylib(兼容性版本7.0.0,当前版本7.0.0)
@ rpath / libtbb.dylib(兼容性版本0.0.0,当前版本0.0.0)
@ rpath / libtbb_debug.dylib(兼容性版本0.0.0,当前版本0.0.0)
@ rpath / libtbbmalloc_debug.dylib(兼容性版本0.0.0,当前版本0.0.0)
@ rpath / libtbbmalloc_proxy.dylib兼容性版本0.0.0,当前版本0.0.0)
@ rpath / libtbbmalloc_proxy_debug.dylib(兼容性版本0.0.0,当前版本0.0.0)
@ rpath / libtbb_preview.dylib(兼容性版本0.0。 0,当前版本0.0.0)
@ rpath / libtbb_preview_debug.dylib(兼容性版本0.0.0,当前版本0.0.0)
@ rpath / libquazip.1.dylib(兼容性版本1.0.0,当前版本1.0.0)
@executable_path /../ Frameworks / libprotobuf.9.dylib(兼容版本10.0.0,当前版本10.1.0)
@ rpath / QtQml.framework /版本/ 5 / QtNetwork(兼容版本5.5.0,当前版本5.5.1)
@rpath / QtNetwork.framework / Versions / 5 / QtNetwork /qtWidgets.framework/Versions/5/QtWidgets(兼容性版本5.5.0,当前版本5.5.1)
@ rpath / QtGui.framework / Versions / 5 / QtGui(兼容性版本5.5.0,当前版本5.5。
@ rpath / QtCore.framework / Versions / 5 / QtCore(兼容性版本5.5.0,当前版本5.5.1)
/usr/lib/libc++.1.dylib(兼容性版本1.0。 0,当前版本120.1.0)
/usr/lib/libSystem.B.dylib(兼容性版本1.0.0,当前版本1226.10.1)
步骤3:
然而我注意到我的project2.app/Contents/Frameworks里面没有这些库。所以我决定手动复制它们。
cp /usr/local/lib/libosg.141.dylib project2.app/Contents /Frameworks/libosg.141.dylib
cp /usr/local/lib/libosgDB.141.dylib project2.app/Contents/Frameworks/libosgDB.141.dylib
cp / usr / local / lib / libosgGA.141.dylib project2.app/Contents/Frameworks/libosgGA.141.dylib
cp /usr/local/lib/libosgUtil.141.dylib project2.app/Contents/Frameworks/libosgUtil.141.dylib
cp /usr/local/lib/libosgViewer.141.dylib project2.app/Contents/Frameworks/libosgViewer.141.dylib
cp /usr/local/lib/libosgManipulator.141.dylib project2.app/Contents /Frameworks/libosgManipulator.141.dylib
cp /usr/local/lib/libOpenThreads.20.dylib project2.app/Contents/Frameworks/libOpenThreads.20.dylib
您能告诉我复制这些文件后我的后续步骤应该是什么?
输出,当我尝试在另一台计算机上运行应用程序而不使用install_name_tool
Dyld错误消息:
库未加载:libosgUtil.141.dylib
引用自:/Users/one/Desktop/project2.app/Contents/Frameworks/libosgDB.141.dylib
原因:找不到图片
二进制图像:
0x7fff6c436000-0x7fff6c46c837 dyld(353.2.1)< 65DCCB06-339C-3E25-9702-600A28291D0E> / usr / lib / dyld
更新:
$ b
经过一些努力,我决定做以下事情:
install_name_tool -change libosg.141.dylib @executable_path /../ Frameworks / libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgDB.141.dylib @ executable_path / .. /Frameworks/libosgDB.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgGA.141.dylib @executable_path /../ Frameworks / libosgGA。 141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgUtil.141.dylib @executable_path /../ Frameworks / libosgUtil.141.dylib / Users /Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgViewer.141.dylib @executable_path /../ Frameworks / libosgViewer.141.dylib / Users / Guest / project_XCODE / bin / Release / project2.app / Contents / MacOS / project2
install_name_tool -change libosgManipulator.141.dylib @executable_path /../ Frameworks / libosgManipulator.141.dylib / Users / Guest / project_XCODE / bin / Release / project2 .app / Contents / MacOS / project2
install_name_tool -change libOpenThreads.20.dylib @executable_path /../ Frameworks / libOpenThreads.20.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/ MacOS / project2
这似乎并没有解决这个问题,
otool -L libosgDB.141.dylib
libosgDB.141.dylib:
@executable_path /../ Frameworks / libosgDB.141.dylib(兼容版本141.0.0,当前版本3.5.1)
libosgUtil.141.dylib(兼容版本141.0.0,当前版本3.5.1) < ----- !!!为什么这不改变!!!!!
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon(兼容性版本2.0.0,当前版本157.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/
/usr/lib/libSystem.B.dylib(兼容性版本1.0.0,当前版本1226.10.1)
/ usr / A / Cocoa(兼容性版本1.0.0,当前版本22.0.0) lib / libz.1.dylib(兼容性版本1.0.0,当前版本1.2.5)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL(兼容性版本1.0.0,当前版本1.0 .0)
libosg.141.dylib(兼容版本141.0.0,当前版本3.5.1)< ----- !!!为什么这不改变!!!!!
libOpenThreads.20.dylib(兼容版本20.0.0,当前版本3.3.0)< ----- !!!为什么这不改变!!!!!
/usr/lib/libc++.1.dylib(兼容性版本1.0.0,当前版本120.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation(兼容性版本150.0.0,当前版本1256.14.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation(兼容性版本300.0.0,当前版本1256.1.0)
/ usr / lib / libobjc.A.dylib(兼容性版本1.0.0,当前版本为228.0.0)
我仍然没有获取库的路径 libOpenThreads.20.dylib,libosgUtil.141.dylib和libosg.141.dylib
任何建议将是非常欢迎。
libosg.141.dylib
是一个dylib, app。
你应该看看应用程序的二进制文件...:
code> otool -L /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
至于将库的路径重置为指向 @executable_path /../ Frameworks / libosg.141.dylib
,而不是dylib在 / usr / local / lib
中,尝试执行以下操作:
install_name_tool -change libosg.141.dylib @executable_path /../ Frameworks / libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
I finished my mac app using Xcode and Qt. Now I would like to prepare it for deployment to other macs. Inorder to do that I utilized macdeployqt.
I just created an app bundle with macdeployqt. However some of the libraries are missing. I attempted to follow [this][1] answer. Turns out I need to copy the missing dylib from my computer to the .app and then run install name tool. I have not gotten to the install-name tool yet as I am confused as to use -id
or -change
with it especially in my current scenario. Do I even need to use it ? Here is what I did so far.
Step 1: Running macdeployqt - this is a program that comes with Qt and embeds the necessary requirements of qt into the app.
> /Users/Guest/Qt/5.5/clang_64/bin/macdeployqt project2.app
Step 2: I then decided to run otool on the actual generated app binary
> pwd
/Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS
> otool -L project2
project2:
@rpath/libcreatecore_rt.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.5.0, current version 5.5.1)
@rpath/QtConcurrent.framework/Versions/5/QtConcurrent (compatibility version 5.5.0, current version 5.5.1)
@rpath/QtSvg.framework/Versions/5/QtSvg (compatibility version 5.5.0, current version 5.5.1)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/libosg.141.dylib (compatibility version 141.0.0, current version 3.5.1)
@executable_path/../Frameworks/libosgDB.141.dylib (compatibility version 141.0.0, current version 3.5.1)
@executable_path/../Frameworks/libosgGA.141.dylib (compatibility version 141.0.0, current version 3.5.1)
@executable_path/../Frameworks/libosgUtil.141.dylib (compatibility version 141.0.0, current version 3.5.1)
@executable_path/../Frameworks/libosgViewer.141.dylib (compatibility version 141.0.0, current version 3.5.1)
@executable_path/../Frameworks/libosgManipulator.141.dylib (compatibility version 141.0.0, current version 3.5.1)
@executable_path/../Frameworks/libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
@rpath/libtbb.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtbb_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtbbmalloc_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtbbmalloc_proxy.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtbbmalloc_proxy_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtbb_preview.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtbb_preview_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libquazip.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/libprotobuf.9.dylib (compatibility version 10.0.0, current version 10.1.0)
@rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.5.0, current version 5.5.1)
@rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.5.0, current version 5.5.1)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.5.0, current version 5.5.1)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.1)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
Step 3: However I noticed that my project2.app/Contents/Frameworks does not have those libraries inside them. So I decided to copy them manually.
cp /usr/local/lib/libosg.141.dylib project2.app/Contents/Frameworks/libosg.141.dylib
cp /usr/local/lib/libosgDB.141.dylib project2.app/Contents/Frameworks/libosgDB.141.dylib
cp /usr/local/lib/libosgGA.141.dylib project2.app/Contents/Frameworks/libosgGA.141.dylib
cp /usr/local/lib/libosgUtil.141.dylib project2.app/Contents/Frameworks/libosgUtil.141.dylib
cp /usr/local/lib/libosgViewer.141.dylib project2.app/Contents/Frameworks/libosgViewer.141.dylib
cp /usr/local/lib/libosgManipulator.141.dylib project2.app/Contents/Frameworks/libosgManipulator.141.dylib
cp /usr/local/lib/libOpenThreads.20.dylib project2.app/Contents/Frameworks/libOpenThreads.20.dylib
Could you tell me what my next steps should be after copying those files ?
This is the output that I get when I attempt to run the app on another computer without using install_name_tool
Dyld Error Message:
Library not loaded: libosgUtil.141.dylib
Referenced from: /Users/one/Desktop/project2.app/Contents/Frameworks/libosgDB.141.dylib
Reason: image not found
Binary Images:
0x7fff6c436000 - 0x7fff6c46c837 dyld (353.2.1) <65DCCB06-339C-3E25-9702-600A28291D0E> /usr/lib/dyld
Update:
After some struggling I decided to do the following
install_name_tool -change libosg.141.dylib @executable_path/../Frameworks/libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgDB.141.dylib @executable_path/../Frameworks/libosgDB.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgGA.141.dylib @executable_path/../Frameworks/libosgGA.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgUtil.141.dylib @executable_path/../Frameworks/libosgUtil.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgViewer.141.dylib @executable_path/../Frameworks/libosgViewer.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgManipulator.141.dylib @executable_path/../Frameworks/libosgManipulator.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libOpenThreads.20.dylib @executable_path/../Frameworks/libOpenThreads.20.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
That did not seem to solve the problem as when I did this to one of the libraries that I just had added.
otool -L libosgDB.141.dylib
libosgDB.141.dylib:
@executable_path/../Frameworks/libosgDB.141.dylib (compatibility version 141.0.0, current version 3.5.1)
libosgUtil.141.dylib (compatibility version 141.0.0, current version 3.5.1) <-----!!!Why did this not change!!!!!
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
libosg.141.dylib (compatibility version 141.0.0, current version 3.5.1) <-----!!!Why did this not change!!!!!
libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)<-----!!!Why did this not change!!!!!
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1256.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
I am still not getting paths for the libraries libOpenThreads.20.dylib , libosgUtil.141.dylib and libosg.141.dylib
any suggestions would be more than welcome.
libosg.141.dylib
is a dylib that you're including in your built app.
You should actually look in your app's binary... that is:
otool -L /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
As for resetting the path of the library to point to "@executable_path/../Frameworks/libosg.141.dylib
" instead of the dylib in "/usr/local/lib
", try doing this:
install_name_tool -change libosg.141.dylib @executable_path/../Frameworks/libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
这篇关于install-name-tool通过otool查看时不会添加库路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!