Deploying Qt/MacOS applications
Hi people,
I'm asking for your help because I've got a problem that I'm not able to understand how to fix.
I've created a Qt application on MacOS X through XCode. The application works fine on my Mac, but I'd like also to redistribute it (ie, make it downloadable from my home page). I've compiled the application in Release mode and then I've used the application provided here in order to include into the package the Qt libraries as well.
I've tried to execute the application on a different machine (without the Qt installed) and it works. The only problem is that all the images (a splashscreen and a background) I've used in the application don't appears if the application runs on a computer different from the mine!
In XCode I'm using the following RCC file (created by qmake along with my .xcodeproject file):
Code:
<RCC>
<qresource prefix="/" >
<file>images/canary-dwarf.jpg</file>
<file>images/canary-dwarf-clear.jpg</file>
<file>images/uop.gif</file>
<file>icon.icns</file>
</qresource>
</RCC>
Please consider that the icon is correctly visible on the other machine.
I've tried to insert the above files (canary-dwarf.jpg, canary-dwarf-clear.jpg and uop.gif) in various locations inside the application package (in "Contents", in "Contents/Resources" and also in "Content/Resources/images") but nothing has changed.
Any clues? :-(
Cheers,
Re: Deploying Qt/MacOS applications
You need to deploy imageformats plugins on the target machine as well.
Re: Deploying Qt/MacOS applications
Thank you very much for your quick reply, wisota... I'll take a look to it immediately!
Re: Deploying Qt/MacOS applications
Hi,
I tried to deploy the imageformats plugin along with my application - following your hint - but I'm still encountering the same problem as before.
I strictly followed the procedure suggested on the QtAssistant, ie:
- I've modified my main.cpp file, adding the following code immediately after the creation of the QApplication:
Code:
dir.cdUp();
dir.cd("plugins");
- I've built my application in Release modality.
- I've included QtGui and QtCore in my application (through the "deployqt" utility).
- I've copied the files contained in /path/to/Qt/plugins/imageformats to myapplication.app/Contents/plugins/imageformats.
- I've linked the jpeg plugin to the frameworks contained in the bundle, using exactly these instructions:
Code:
install_name_tool -change /Library/Frameworks/QtGui.framework/Versions/4/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui MAVs_A1.app/Contents/plugins/imageformats/libqjpeg.dylib
install_name_tool -change /Library/Frameworks/QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore MAVs_A1.app/Contents/plugins/imageformats/libqjpeg.dylib
The application works but without images... :-(
Cheers,
Fabio
Re: Deploying Qt/MacOS applications
Try without the "plugins" folder, as described here:
http://www.qtcentre.org/forum/faq.ph...missing_images
You can then ignore the step with library paths.
Try first without creating the bundle (just deploy all the files directly) and see if it works, because if not, then there is something else wrong and there is no point in battling the bundle.
Re: Deploying Qt/MacOS applications
Problem solved! Finally! :-)
This is a guideline that I've prepared for myself, after I've fixed the bug. I hope it will be useful for someone else as well.
1 - Modify the main.cpp, inserting this code immediately after the instruction that creates the QApplication:
Code:
QDir dir
(app.
applicationDirPath());
dir.cdUp();
dir.cd("Plugins");
2 - Enter the directory where all the sources are located;
3 - Generate a project file through qmake (qmake -project);
4 - Edit the .pro file created by qmake, adding this new line in order to include in the bundle also the application’s icon:
5 - Generate an XCode project (qmake -spec macx-xcode filename.pro);
6 - Open the project in XCode and then build everything in Release mode:
7 - Go to the Terminal and use the deployqt tool to add QtGui and QtCore frameworks and imageformat plugin to the application package:
Code:
deployqt application.app /Developer/Applications/Qt/plugins/imageformats;
8 - Enter the bundle and move the imageformats files - automatically deployed in “Contents/Plugins†- to “Contents/Plugins/imageformatsâ€;
9 - Put the resulting application inside a compressed image through Disk Utility and then create a compressed archive;
10 - Distribute the application to everyone might be interested on it! :-)
Many thanks to Wisota, which has addressed me to the right point!