简体   繁体   English

Qt .nib在MacOS上发布问题

[英]Qt .nib issues on MacOS

I'm trying to deploy a Qt C++ application on another mac that doesn't have Qt installed. 我正在尝试在另一台没有安装Qt的mac上部署Qt C ++应用程序。 I am getting a "Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/ or in the resources directory of your application bundle." 我收到“Qt内部错误:无法加载qt_menu.nib。.nib文件应放在QtGui.framework / Versions / Current / Resources /或应用程序包的resources目录中。”

I've tried packing qt_menu.lib into both suggested places, with no success: 我已经尝试将qt_menu.lib打包到两个建议的位置,但没有成功:

$ ls ./arya.app/Resources/
qt_menu.nib
$ ./arya.app/Contents/MacOS/arya 
Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/  or in the resources directory of your application bundle.

or: 要么:

$ mkdir QtGui.framework
$ mkdir QtGui.framework/Versions/
$ mkdir QtGui.framework/Versions/Current/
$ mkdir QtGui.framework/Versions/Current/Resources
$ mv ./arya.app/Resources/qt_menu.nib QtGui.framework/Versions/Current/Resources/
$ ./arya.app/Contents/MacOS/arya 
Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/  or in the resources directory of your application bundle.

I'm not sure if there may be some connection, but I had some issues with dylib paths before this. 我不确定是否有某些连接,但在此之前我遇到了一些dylib路径问题。 After stumbling about with install_name_tool, I 'solved' them with: 在使用install_name_tool磕磕绊绊之后,我'解决了'他们:

export DYLD_LIBRARY_PATH=.

before running the application. 在运行应用程序之前。

Building the application with 使用。构建应用程序

CONFIG -= app_bundle

made no difference. 没有区别。

After battling this same problem from another application, I've managed to pin down the exact commands that easily solve this .nib issue: 在从另一个应用程序中解决同样的问题后,我设法确定了可以轻松解决此.nib问题的确切命令:

mkdir -p application.app/Contents/Frameworks/QtGui.framework/Resources
cp -r $(QTLIBDIR)/QtGui.framework/Versions/4/Resources/qt_menu.nib application.app/Contents/Frameworks/QtGui.framework/Resources

This does not address other issues on deploying for mac - just the .nib problem. 这并没有解决有关部署mac的其他问题 - 只是.nib问题。

Try this: 试试这个:

(1) Remove your export DYLD_LIBRARY_PATH=. (1)删除export DYLD_LIBRARY_PATH=.

(2) Remove your CONFIG -= app_bundle (2)删除你的CONFIG -= app_bundle

(3) Put QT frameworks into ./arya.app/Contents/Frameworks (3)将QT框架放入./arya.app/Contents/Frameworks

Ie all the contents of QtGui.framework into ./arya.app/Contents/Frameworks/QtGui.framework , QtCore.framework into ./arya.app/Contents/Frameworks/QtCore.framework , etc. 即所有QtGui.framework的内容转换成./arya.app/Contents/Frameworks/QtGui.framework,QtCore.framework./arya.app/Contents/Frameworks/QtCore.framework等。

So your qt_menu.nib will automatically be a ./arya.app/Contents/Frameworks/QtGui.framework/Versions/Current/Resources/qt_menu.nib 所以你的qt_menu.nib会自动成为./arya.app/Contents/Frameworks/QtGui.framework/Versions/Current/Resources/qt_menu.nib

Try running macdeployqt on your .app after building it. 在构建之后尝试在.app上运行macdeployqt It copies the needed Qt frameworks (and any other needed dylibs ) into the bundle and fixes up the binary's link paths so it knows to link in Qt from it's own bundle. 它将所需的Qt框架(以及任何其他所需的dylibsdylibs到bundle中并修复二进制文件的链接路径,以便它知道在Qt中链接它自己的bundle。

(It also has a bug that causes any libraries with paths not ending in lib/ (like /opt/local/lib/opencv/cv.lib to not be copied correctly, but there's a one-line source fix for this) (它还有一个错误,导致任何路径不以lib/结尾的lib/ (如/opt/local/lib/opencv/cv.lib不能正确复制,但有一个单行源修复)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM