PDA

View Full Version : Unable to load jpg on Mac OS



sgmurphy19
29th January 2008, 07:29
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


QImage tempImage;
if(tempImage.load(tempImageFileName))
{
/*
/users/images/test.JPG does not work
but
/users/images/test.PNG does work
*/
}
else
{
QMessageBox::information(NULL, "Test QImage Load", "Unable to load image: " + tempImageFileName);
}

marcel
29th January 2008, 07:55
Maybe you don't have the jpeg plugin...
Take a look and see if you got qjpeg4.*.

Regards

sgmurphy19
29th January 2008, 13:41
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.

sgmurphy19
29th January 2008, 14:26
I do not have the plugin qjpeg4 though... I only have what I assume is qjpeg (the file is libqjpeg.dylib)

wysota
29th January 2008, 18:45
http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_missing_ima ges

tommy
30th January 2008, 00:05
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

sgmurphy19
30th January 2008, 18:46
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!

wysota
30th January 2008, 21:52
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?

sgmurphy19
30th January 2008, 22:14
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 :(

wysota
30th January 2008, 22:59
Did you follow the FAQ entry I pointed you to?

sgmurphy19
31st January 2008, 00:05
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 ;)

wysota
31st January 2008, 01:24
Make a directory structure like this:

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

sgmurphy19
31st January 2008, 03:56
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


Make a directory structure like this:

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

wysota
31st January 2008, 10:40
Get rid of CONFIG+=static and QTPLUGIN+=qjpeg

sgmurphy19
31st January 2008, 13:49
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!