MacOS 上的 Qt .nib 问题
我正在尝试在另一台未安装 Qt 的 Mac 上部署 Qt C++ 应用程序。我收到“Qt 内部错误:无法加载 qt_menu.nib。.nib 文件应放置在 QtGui.framework/Versions/Current/Resources/ 中或应用程序包的资源目录中。”
我尝试将 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.
或者:
$ 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.
我不确定是否存在某种连接,但在此之前我遇到了 dylib 路径的一些问题。在使用 install_name_tool 绊倒之后,我用以下方法“解决”了它们:
export DYLD_LIBRARY_PATH=.
在运行应用程序之前。
构建应用程序
CONFIG -= app_bundle
没有什么区别。
I'm trying to deploy a Qt C++ application on another mac that doesn't have Qt installed. 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."
I've tried packing qt_menu.lib into both suggested places, with no success:
$ 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. After stumbling about with install_name_tool, I 'solved' them with:
export DYLD_LIBRARY_PATH=.
before running the application.
Building the application with
CONFIG -= app_bundle
made no difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在从另一个应用程序中解决了同样的问题后,我设法确定了可以轻松解决此 .nib 问题的确切命令:
这并不能解决在 mac 上部署的其他问题 - 只是解决 .nib 问题。
After battling this same problem from another application, I've managed to pin down the exact commands that easily solve this .nib issue:
This does not address other issues on deploying for mac - just the .nib problem.
试试这个:
(1) 删除您的
export DYLD_LIBRARY_PATH=.
(2) 删除您的
CONFIG -= app_bundle
(3) 将 QT 框架放入 ./arya.app/Contents/框架
即将 QtGui.framework 的所有内容放入 ./arya.app/Contents/Frameworks/QtGui.framework,
QtCore.framework 到 ./arya.app/Contents/Frameworks/QtCore.framework 等。
因此您的 qt_menu.nib 将自动成为 ./arya.app/Contents /Frameworks/QtGui.framework/Versions/Current/Resources/qt_menu.nib
Try this:
(1) Remove your
export DYLD_LIBRARY_PATH=.
(2) Remove your
CONFIG -= app_bundle
(3) Put QT frameworks into ./arya.app/Contents/Frameworks
I.e. all the contents of QtGui.framework into ./arya.app/Contents/Frameworks/QtGui.framework,
QtCore.framework into ./arya.app/Contents/Frameworks/QtCore.framework, etc.
So your qt_menu.nib will automatically be a ./arya.app/Contents/Frameworks/QtGui.framework/Versions/Current/Resources/qt_menu.nib
尝试运行
macdeployqt<构建后在
.app
上使用 /code>。它将所需的 Qt 框架(以及任何其他所需的 dylibs)复制到捆绑包中,并修复二进制文件的链接路径,以便它知道从自己的捆绑包中链接到 Qt。
(它还有一个错误,导致任何路径不以
lib/
结尾的库(例如/opt/local/lib/opencv/cv.lib
)无法正确复制,但是有一个单行源代码可以解决这个问题)Try running
macdeployqt
on your.app
after building it. It copies the needed Qt frameworks (and any other neededdylibs
) into the bundle and fixes up the binary's link paths so it knows to link in Qt from it's own 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)