3

我使用 Xcode 和 Qt 完成了我的 mac 应用程序。现在我想准备将其部署到其他 Mac。为了做到这一点,我使用了 macdeployqt。

我刚刚使用 macdeployqt 创建了一个应用程序包。然而,一些图书馆不见了。我试图遵循 [this][1] 的答案。原来我需要将丢失的 dylib 从我的计算机复制到 .app,然后运行安装名称工具。我还没有使用 install-name 工具,因为我对使用-id-change使用它感到困惑,尤其是在我目前的情况下。我什至需要使用它吗?这是我到目前为止所做的。

第 1 步:运行 macdeployqt - 这是 Qt 附带的程序,将 qt 的必要要求嵌入到应用程序中。

> /Users/Guest/Qt/5.5/clang_64/bin/macdeployqt project2.app

第 2 步:然后我决定在实际生成的应用程序二进制文件上运行 otool

> 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)

第 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 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

更新:

经过一番挣扎后,我决定执行以下操作

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 (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)

我仍然没有获得图书馆的路径,libOpenThreads.20.dylib , libosgUtil.141.dylib and libosg.141.dylib 任何建议都会受到欢迎。

4

1 回答 1

3

libosg.141.dylib是您构建的应用程序中包含的 dylib。

您实际上应该查看应用程序的二进制文件......即:

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
于 2016-02-03T19:40:07.643 回答