简体   繁体   中英

Qt .nib issues on MacOS

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.

After battling this same problem from another application, I've managed to pin down the exact commands that easily solve this .nib issue:

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.

Try this:

(1) Remove your export DYLD_LIBRARY_PATH=.

(2) Remove your CONFIG -= app_bundle

(3) Put QT frameworks into ./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.

So your qt_menu.nib will automatically be a ./arya.app/Contents/Frameworks/QtGui.framework/Versions/Current/Resources/qt_menu.nib

Try running macdeployqt on your .app after building it. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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