Results 1 to 15 of 15

Thread: Unable to load jpg on Mac OS

  1. #1
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Unable to load jpg on Mac OS

    This code works perfectly on the pc, as well as on the mac but only for .png files. I've seen other threads on this, but none that address QImage loading on windows but not the macOS. I put the imageformats folder in the package too. It doesn't even work on the development machine. Any help is greatly appreciated!

    Sean

    Qt Code:
    1. QImage tempImage;
    2. if(tempImage.load(tempImageFileName))
    3. {
    4. /*
    5. /users/images/test.JPG does not work
    6. but
    7. /users/images/test.PNG does work
    8. */
    9. }
    10. else
    11. {
    12. QMessageBox::information(NULL, "Test QImage Load", "Unable to load image: " + tempImageFileName);
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 29th January 2008 at 11:43. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to load jpg on Mac OS

    Maybe you don't have the jpeg plugin...
    Take a look and see if you got qjpeg4.*.

    Regards

  3. #3
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I added this line to my .pro file:
    QTPLUGIN += qjpeg

    And now the app compiles but it will not launch. When I run console behind it I get this error:
    dyld: Library not loaded: /var/tmp//ccZyqtTj.out
    Referenced from: /Users/sgmurphy/Projects/MyAPP_QT/build_mac/MyAPP.app/Contents/MacOS/MyAPP
    Reason: image not found

    Any ideas?
    P.S. I have not yet added
    #include <QtPlugin> or Q_IMPORT_PLUGIN(qjpeg) to my main.cpp yet.

  4. #4
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I do not have the plugin qjpeg4 though... I only have what I assume is qjpeg (the file is libqjpeg.dylib)

  5. #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

  6. #6
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Unable to load jpg on Mac OS

    I was struggling with similar things myself and figured certain things out, so I might be able to help you. I know nothing about Mac but something tells me this is not a Mac problem.
    Questions to you: Are you trying to compile statically or dynamically? How did you install your Qt?

    Even with Qt4 your plugin is not called qjpeg4 if you do static linking. And from your description it seems like you do static.
    In you *pro file, is it possible you forgot to add CONFIG += staticlib

  7. #7
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I installed from the mac disk image. I added the Config += staticlib and still no go.

    Funny thing is that after adding only the lines:
    QTPLUGIN += qjpeg \
    qgif \
    qtiff

    to the .pro file the result of running otool -L on the app is:

    /var/tmp//cclMLi3H.out (compatibility version 0.0.0, current version 0.0.0)
    /var/tmp//cc4kc0Kd.out (compatibility version 0.0.0, current version 0.0.0)
    /var/tmp//ccLv2JaH.out (compatibility version 0.0.0, current version 0.0.0)
    QtSql.framework/Versions/4/QtSql (compatibility version 4.3.0, current version 4.3.3)
    QtXml.framework/Versions/4/QtXml (compatibility version 4.3.0, current version 4.3.3)
    QtGui.framework/Versions/4/QtGui (compatibility version 4.3.0, current version 4.3.3)

    why would these phantom .out (I call them phantom because they don't exist) be listed?

    Thanks!

  8. #8
    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: Unable to load jpg on Mac OS

    They are probably some static objects linked into the binary. Answer this question please - are you compiling in static mode on purpose or just because you didn't manage to make the shared approach work?

  9. #9
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I didn't want to compile in static, I added that at the recommendation of an above post. If I leave the config += static in there or not, the app still has these references

  10. #10
    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: Unable to load jpg on Mac OS

    Did you follow the FAQ entry I pointed you to?

  11. #11
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I did but to no avail. I even manually added the plugin path (and tested that it was being used by putting the dir for my sqlite lib in it) but still nothing.

    If I don't include the QTPLUGIN += qjpeg in my .pro file, then there is no jpg support.

    If I do include QTPLUGIN += qjpeg in my .pro file, then When I launch my app (it does successfully compile) I get a reference error and it won't launch. This is the error: dyld: Library not loaded: /var/tmp//cclMLi3H.out

    If I run otool -L on the app it returns that file in the list of depended libs.:

    /var/tmp//cclMLi3H.out (compatibility version 0.0.0, current version 0.0.0)
    QtSql.framework/Versions/4/QtSql (compatibility version 4.3.0, current version 4.3.3)
    QtXml.framework/Versions/4/QtXml (compatibility version 4.3.0, current version 4.3.3)
    etc...

    Yikes! Its been a while since I've been this lost and now I know why I don't get here very often

  12. #12
    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: Unable to load jpg on Mac OS

    Make a directory structure like this:

    somedir <--directory
    somedir/yourapplicationbinary <-- program binary
    somedir/imageformats <-- directory
    somedir/imageformats/qjpeg.dylib <-- image plugin

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

    sgmurphy19 (31st January 2008)

  14. #13
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I created a new
    MyApp
    MyApp/src
    MyApp/imageformats (and placed the qjpeg.dylib in it)

    The result was exactly the same

    Here is the top part of my .pro file if that makes some difference
    TEMPLATE = app

    CONFIG += release

    CONFIG += static

    CONFIG += qt warn_on thread

    QT += sql
    QT += xml

    QT += network

    DEPENDPATH += .
    QTPLUGIN += qjpeg

    Thanks again for trying to help with this.
    Sean

    Quote Originally Posted by wysota View Post
    Make a directory structure like this:

    somedir <--directory
    somedir/yourapplicationbinary <-- program binary
    somedir/imageformats <-- directory
    somedir/imageformats/qjpeg.dylib <-- image plugin

  15. #14
    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: Unable to load jpg on Mac OS

    Get rid of CONFIG+=static and QTPLUGIN+=qjpeg

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

    sgmurphy19 (31st January 2008)

  17. #15
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Unable to load jpg on Mac OS

    I decided to reinstall QT, but this time from the binaries instead of the package. I also took the two lines out of my .pro file and the jpg support is now there. So thank you so much for all your help!!! Wow, 2 days on that. Now I'm behind but it's working. Thanks again so much!

Similar Threads

  1. Program not compiling on Fresh install of Leopard
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:22
  2. Deploying debug Qt application - failed to load ODBC driver
    By sureshbabu in forum Installation and Deployment
    Replies: 1
    Last Post: 1st November 2007, 12:35
  3. Qt4 does not load JPG's.
    By Teuniz in forum Qt Programming
    Replies: 3
    Last Post: 3rd September 2007, 23:06
  4. Replies: 2
    Last Post: 13th September 2006, 09:11
  5. QProcess / system call not working under linux. Why?
    By johnny_sparx in forum Qt Programming
    Replies: 12
    Last Post: 11th March 2006, 00:32

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.