Results 1 to 6 of 6

Thread: Deploying Qt/MacOS applications

  1. #1
    Join Date
    Jun 2007
    Location
    Plymouth, UK
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy 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):

    Qt Code:
    1. <RCC>
    2. <qresource prefix="/" >
    3. <file>images/canary-dwarf.jpg</file>
    4. <file>images/canary-dwarf-clear.jpg</file>
    5. <file>images/uop.gif</file>
    6. <file>icon.icns</file>
    7. </qresource>
    8. </RCC>
    To copy to clipboard, switch view to plain text mode 

    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,

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Deploying Qt/MacOS applications

    You need to deploy imageformats plugins on the target machine as well.

  3. The following user says thank you to wysota for this useful post:

    fabietto (3rd October 2007)

  4. #3
    Join Date
    Jun 2007
    Location
    Plymouth, UK
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Deploying Qt/MacOS applications

    Thank you very much for your quick reply, wisota... I'll take a look to it immediately!

  5. #4
    Join Date
    Jun 2007
    Location
    Plymouth, UK
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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:

    Qt Code:
    1. QDir dir(QApplication::applicationDirPath());
    2. dir.cdUp();
    3. dir.cd("plugins");
    4. QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
    To copy to clipboard, switch view to plain text mode 

    - 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:

    Qt Code:
    1. 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
    2.  
    3. 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
    To copy to clipboard, switch view to plain text mode 

    The application works but without images... :-(

    Cheers,
    Fabio

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  7. #6
    Join Date
    Jun 2007
    Location
    Plymouth, UK
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile 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:

    Qt Code:
    1. QDir dir(app.applicationDirPath());
    2. dir.cdUp();
    3. dir.cd("Plugins");
    4. app.setLibraryPaths(QStringList(dir.absolutePath()));
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. ICON = icon.icns
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. deployqt application.app /Developer/Applications/Qt/plugins/imageformats;
    To copy to clipboard, switch view to plain text mode 

    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!
    Last edited by fabietto; 3rd October 2007 at 17:47. Reason: spelling error

  8. The following user says thank you to fabietto for this useful post:

    THRESHE (5th December 2007)

Similar Threads

  1. Deploying QT applications
    By SteM in forum Installation and Deployment
    Replies: 3
    Last Post: 6th June 2007, 11:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.