Her*_*ang 2 macos qt otool dyld macdeployqt
我使用的是Qt Creator 3.6.1用Qt 5.6.0 (Clang 7.0 (Apple), 64 bit)了,我遇到了一些问题,而试图创建一个用于部署的应用程序包.
注意:调用应用程序名称 bibi
Qt Creatorbibi.app在build-bibi-Desktop_Qt_5_6_0_clang_64bit-Release/文件夹下成功生成bibi.app无法在其他Mac上成功链接Qtmacdeployqt 没有解决问题以下是详细信息:
otool
> otool -L build-bibi-Desktop_Qt_5_6_0_clang_64bit-Release/bibi.app/Contents/MacOS/bibi
build-bibi-Desktop_Qt_5_6_0_clang_64bit-Release/bibi.app/Contents/MacOS/bibi:
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/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)
Run Code Online (Sandbox Code Playgroud)
macdeployqt
> which macdeployqt
/Users/<myusername>/Qt/5.6/clang_64/bin/macdeployqt
> macdeployqt bibi.app
> otool -L bibi.app/Contents/MacOS/bibi
bibi.app/Contents/MacOS/bibi:
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/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)
Run Code Online (Sandbox Code Playgroud)
树bibi.app
bibi.app
??? Contents
? ??? Frameworks
? ? ??? QtCore.framework
? ? ? ??? QtCore -> Versions/Current/QtCore
? ? ? ??? Resources -> Versions/Current/Resources
? ? ? ??? Versions
? ? ? ??? 5
? ? ? ? ??? QtCore
? ? ? ? ??? Resources
? ? ? ? ??? Info.plist
? ? ? ??? Current -> 5
? ? ??? QtDBus.framework
? ? ? ??? QtDBus -> Versions/Current/QtDBus
? ? ? ??? Resources -> Versions/Current/Resources
? ? ? ??? Versions
? ? ? ??? 5
? ? ? ? ??? QtDBus
? ? ? ? ??? Resources
? ? ? ? ??? Info.plist
? ? ? ??? Current -> 5
? ? ??? QtGui.framework
? ? ? ??? QtGui -> Versions/Current/QtGui
? ? ? ??? Resources -> Versions/Current/Resources
? ? ? ??? Versions
? ? ? ??? 5
? ? ? ? ??? QtGui
? ? ? ? ??? Resources
? ? ? ? ??? Info.plist
? ? ? ??? Current -> 5
? ? ??? QtPrintSupport.framework
? ? ? ??? QtPrintSupport -> Versions/Current/QtPrintSupport
? ? ? ??? Resources -> Versions/Current/Resources
? ? ? ??? Versions
? ? ? ??? 5
? ? ? ? ??? QtPrintSupport
? ? ? ? ??? Resources
? ? ? ? ??? Info.plist
? ? ? ??? Current -> 5
? ? ??? QtWidgets.framework
? ? ??? QtWidgets -> Versions/Current/QtWidgets
? ? ??? Resources -> Versions/Current/Resources
? ? ??? Versions
? ? ??? 5
? ? ? ??? QtWidgets
? ? ? ??? Resources
? ? ? ??? Info.plist
? ? ??? Current -> 5
? ??? Info.plist
? ??? MacOS
? ? ??? bibi
? ??? PkgInfo
? ??? PlugIns
? ? ??? imageformats
? ? ? ??? libqdds.dylib
? ? ? ??? libqgif.dylib
? ? ? ??? libqicns.dylib
? ? ? ??? libqico.dylib
? ? ? ??? libqjpeg.dylib
? ? ? ??? libqtga.dylib
? ? ? ??? libqtiff.dylib
? ? ? ??? libqwbmp.dylib
? ? ? ??? libqwebp.dylib
? ? ??? platforms
? ? ? ??? libqcocoa.dylib
? ? ??? printsupport
? ? ??? libcocoaprintersupport.dylib
? ??? Resources
? ??? empty.lproj
? ??? qt.conf
??? Icon\r
38 directories, 32 files
Run Code Online (Sandbox Code Playgroud)
谢谢.
谢谢scottt,问题解决了.以下是我无法成功创建自包含应用包的原因:
otool -L 没有解决@rpath,我很困惑,因为它总是给我相同的输出总之,这个问题可以通过使用斯科特的被解决otool-rpath,lsof或设置DYLD_PRINT_LIBRARIES和DYLD_PRINT_TO_FILE.而且,我在这里写了一个详细说明.
假设您使用了qt-unified-max-x64-online.dmg安装程序并安装了Qt $HOME/Qt.您可以使用以下内容构建项目:
cd MY-QT-PROJECT
QT_BIN_DIR=$HOME/Qt/5.6/clang_64/bin
make clean
$QT_BIN_DIR/qmake -config release
make -j$(getconf NPROCESSORS_ONLN)
Run Code Online (Sandbox Code Playgroud)
这会创建一个应用程序包,但它不会在常规用户的计算机上运行.
查看捆绑在一起的Mach-O可执行文件中的RPATH:
otool-rpath ./*.app/Contents/MacOS/*
/Users/user/Qt/5.6/clang_64/lib
Run Code Online (Sandbox Code Playgroud)
我正在使用一个小的otool-rpath脚本,我在这里写的是为了说明目的.
RPATH加上otool -L上面输出中列出的安装名称构成动态链接器dyld,查找下面的Qt框架/Users/user/Qt/5.6/clang_64/lib.因此,将不为谁没有在同一个位置安装了Qt用户使用.
要改变它,运行Qt的macdeployqt工具:
$QT_BIN_DIR/macdeployqt ./*.app -verbose=3 -always-overwrite -appstore-compliant
Run Code Online (Sandbox Code Playgroud)
请在此处查看示例macdeployqt日志.
macdeployqt创建自包含的应用程序包.观察可执行文件中的RPATH如何从以下/Users/user/Qt/5.6/clang_64/lib变为@executable_path/../Frameworks:
otool-rpath ./*.app/Contents/MacOS/*
@executable_path/../Frameworks
Run Code Online (Sandbox Code Playgroud)
@executable_path做了明显的事情,并通过扩大dyld至bibi.app/Contents/MacOS在运行时.可执行文件中的RPATH和安装名称一起使捆绑包内的动态链接在运行时工作.
您可以通过设置DYLD_PRINT_LIBRARIES和获取动态链接器如何查找库的日志DYLD_PRINT_TO_FILE.示例日志.见dyld(1).
您可以使用它lsof -p $PID | grep QtCore来检查应用程序在运行时实际使用的框架副本.示例日志.
关键字:" RPATH "," 安装名称 "," Mach-O动态链接 ".
请注意,ELF 中的RPATH具有完全不同的语义.
| 归档时间: |
|
| 查看次数: |
1261 次 |
| 最近记录: |