Results 1 to 2 of 2

Thread: Strange errors on OS X only if libraries are inside application bundle

  1. #1
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Strange errors on OS X only if libraries are inside application bundle

    I was tasked with maintaining a Mac OS X port of a Qt application in Qt Creator (most of the development is done for Windows in Visual Studio). Everything builds fine, and then I am using a script which utilizes macdeployqt to add in Qt dependencies to the application bundle.
    If I try to run this bundle, I get the error: "QWidget: Must construct a QApplication before a QPaintDevice". Running from commandline shows that a series of messages like this precede it:
    Qt Code:
    1. objc[12020]: Class QMacSoundDelegate is implemented in both
    2. /Library/Frameworks/QtGui.framework/Versions/4/QtGui and
    3. /Users/uliggett/Q/NAVY_SBIR_NDE_PII/NLign3D/NLign3D.app/
    4. Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
    5. Using implementation from /Users/uliggett/Q/NAVY_SBIR_NDE_PII/NLign3D/NLign3D.app/
    6. Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
    To copy to clipboard, switch view to plain text mode 
    This happens in both debug mode and release mode.

    If I remove all the Qt libraries from the Contents/Frameworks/ folder of the bundle (I tried this after reading this thread), then the application starts and runs flawlessly, apparently using the Qt libraries from the system path rather than the bundle. However, this is not a viable solution because the bundle is something that we will distribute, likely to users who do not have Qt installed elsewhere.
    I tried directly copying the relevant libraries from the system path into the bundle. This resulted in the new error "QWidget: Cannot create a QWidget when no GUI is being used."
    As far as I can tell, the libraries inside the bundle and the libraries inside /Libraries/Framework etc. are completely identical except that 'otool -L' reports that they are linked against different locations of Qt libraries (i.e. those inside the bundle point to more libraries inside the bundle, while those in the system path point to more in the system path, which makes sense).

    Can anyone shed some light on this issue?

  2. #2
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Strange errors on OS X only if libraries are inside application bundle

    I fixed my own issue eventually. The problem was that all the dylibs with which the main executable was linked were referring to (for instance) QtOpenGL.Framework/Versions/4/OpenGL and it was taking that as a relative path from /Library/Frameworks rather than from the location of the dylib (which would have put it inside the bundle in the proper location). As a result, some parts of the program were referring to different libraries and so Qt had a different context (or something) there.
    While there is probably a better way to solve this, I just added this to the deployment script to work around it temporarily:
    Qt Code:
    1. # Get each dylib to point to the proper location for the Qt libraries -
    2. # that is, inside the bundle, not into /Library/Frameworks.
    3. PREFIX="@executable_path/../Frameworks/"
    4. # (1) Get each dylib (files only - not symlinks) and get the
    5. # main executable too.
    6. find $DESTDIR/NLign3D.app/Contents/Frameworks -type f | egrep "\.dylib$" > /tmp/libs.txt
    7. echo $DESTDIR/NLign3D.app/Contents/MacOS/NLign3D >> /tmp/libs.txt
    8. cat /tmp/libs.txt |
    9. while read LIBNAME
    10. do
    11. # (2) Find any reference to Qt libs that aren't
    12. # via @executable_path/.. etc.
    13. otool -L $LIBNAME |
    14. sed -e "s/^[[:blank:]]*//g" |
    15. egrep "^Qt" |
    16. cut -d ' ' -f 1 |
    17. while read LIBREF
    18. do
    19. # (3) Prefix these refs with $PREFIX so that the
    20. # dylibs look inside the bundle for Qt, rather than
    21. # in /Library/Frameworks.
    22. NEWREF=$PREFIX$LIBREF
    23. install_name_tool -change $LIBREF $NEWREF $LIBNAME
    24. done
    25. done
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Strange Errors while compiling (QT Header Files)
    By DrDonut in forum Qt Programming
    Replies: 5
    Last Post: 21st May 2009, 14:10
  2. Strange errors
    By prykHetQuo in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2009, 19:13
  3. Link errors when linking chained libraries on windows
    By darkadept in forum Qt Programming
    Replies: 5
    Last Post: 26th May 2008, 15:52
  4. Create Qt Application Bundle in MacOs
    By joy in forum Installation and Deployment
    Replies: 2
    Last Post: 25th February 2008, 19:06
  5. HelperTool within Application Bundle?
    By vishal.chauhan in forum Qt Programming
    Replies: 7
    Last Post: 3rd January 2008, 14:19

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.