Qt-interest Archive, December 2006
jpeg missing from supportedImageFormats() in static library
Message 1 in thread
When I build my app with Qt 4.2.2 static,
QImageWriter::supportedImageFormats() is missing "jpeg", but with the
shared Qt library, it's present. Any ideas how I can fix this?
--Dave
--
[ signature omitted ]
Message 2 in thread
Dave Smith wrote:
> When I build my app with Qt 4.2.2 static,
> QImageWriter::supportedImageFormats() is missing "jpeg", but with the
> shared Qt library, it's present. Any ideas how I can fix this?
>
> --Dave
When using a static Qt library, you have to modify your .pro file to
link against the image plugins explicitly.
http://doc.trolltech.com/4.2/plugins-howto.html
Paul.
--
[ signature omitted ]
Message 3 in thread
Paul Koshevoy wrote:
> Dave Smith wrote:
>
>> When I build my app with Qt 4.2.2 static,
>> QImageWriter::supportedImageFormats() is missing "jpeg", but with the
>> shared Qt library, it's present. Any ideas how I can fix this?
>>
>> --Dave
>>
>
> When using a static Qt library, you have to modify your .pro file to
> link against the image plugins explicitly.
> http://doc.trolltech.com/4.2/plugins-howto.html
Thanks for the doc! I've followed the instructions and added this to my
.pro file:
QTPLUGIN += qjpeg
And I added this to the top of the file which contains main():
Q_IMPORT_PLUGIN(qjpeg)
This does indeed change my link line, and I see the -lqjpeg, but I get
several undefined reference errors:
/usr/local/Trolltech/Qt-4.2.2-static/plugins/imageformats//libqjpeg.a(qjpeghandler.o)(.text+0x1789):
In function `read_jpeg_image(QIODevice*, QImage*, QByteArray const&,
QSize, int)':
: undefined reference to `jpeg_resync_to_restart'
/usr/local/Trolltech/Qt-4.2.2-static/plugins/imageformats//libqjpeg.a(qjpeghandler.o)(.text+0x17c3):
In function `read_jpeg_image(QIODevice*, QImage*, QByteArray const&,
QSize, int)':
: undefined reference to `jpeg_CreateDecompress'
And many more. So I added this to my .pro file:
LIBS += -ljpeg
And that seems to have resolved them. I didn't really want to link to
the system libjpeg.a, but oh well. Is that the recommended way to do it?
Whatever the case, this has solved my problem. I was just hoping to link
against Qt's jpeg lib, and not the system lib.
--Dave
--
[ signature omitted ]
Message 4 in thread
Dave Smith wrote:
> Paul Koshevoy wrote:
>> Dave Smith wrote:
>>
>>> When I build my app with Qt 4.2.2 static,
>>> QImageWriter::supportedImageFormats() is missing "jpeg", but with the
>>> shared Qt library, it's present. Any ideas how I can fix this?
>>>
>>> --Dave
>>>
>>
>> When using a static Qt library, you have to modify your .pro file to
>> link against the image plugins explicitly.
>> http://doc.trolltech.com/4.2/plugins-howto.html
>
> Thanks for the doc! I've followed the instructions and added this to
> my .pro file:
>
> QTPLUGIN += qjpeg
>
> And I added this to the top of the file which contains main():
>
> Q_IMPORT_PLUGIN(qjpeg)
>
> This does indeed change my link line, and I see the -lqjpeg, but I get
> several undefined reference errors:
>
> /usr/local/Trolltech/Qt-4.2.2-static/plugins/imageformats//libqjpeg.a(qjpeghandler.o)(.text+0x1789):
> In function `read_jpeg_image(QIODevice*, QImage*, QByteArray const&,
> QSize, int)':
> : undefined reference to `jpeg_resync_to_restart'
> /usr/local/Trolltech/Qt-4.2.2-static/plugins/imageformats//libqjpeg.a(qjpeghandler.o)(.text+0x17c3):
> In function `read_jpeg_image(QIODevice*, QImage*, QByteArray const&,
> QSize, int)':
> : undefined reference to `jpeg_CreateDecompress'
>
> And many more. So I added this to my .pro file:
>
> LIBS += -ljpeg
>
> And that seems to have resolved them. I didn't really want to link to
> the system libjpeg.a, but oh well. Is that the recommended way to do it?
>
> Whatever the case, this has solved my problem. I was just hoping to
> link against Qt's jpeg lib, and not the system lib.
I don't think Qt builds libjpeg explicitly (I don't see it in
$QTDIR/lib), so you either have to build a static libjpeg yourself from
source (which is easy), or you can modify your .pro file to link against
the static version of the system libjpeg as follows:
LIBS += -Wl,-Bstatic -ljpeg -Wl,-Bdynamic
Of course, this assumes a gcc compiler, and I don't think the OS X
linker understands the -Bstatic switch, so that would limit the
portability of your .pro file.
Paul.
--
[ signature omitted ]
Message 5 in thread
Paul Koshevoy wrote:
> Dave Smith wrote:
>
>> Paul Koshevoy wrote:
>>
>>> Dave Smith wrote:
>>>
>> <snip>
>> And many more. So I added this to my .pro file:
>>
>> LIBS += -ljpeg
>>
>> And that seems to have resolved them. I didn't really want to link to
>> the system libjpeg.a, but oh well. Is that the recommended way to do it?
>>
>> Whatever the case, this has solved my problem. I was just hoping to
>> link against Qt's jpeg lib, and not the system lib.
>>
>
> I don't think Qt builds libjpeg explicitly (I don't see it in
> $QTDIR/lib), so you either have to build a static libjpeg yourself from
> source (which is easy), or you can modify your .pro file to link against
> the static version of the system libjpeg as follows:
>
> LIBS += -Wl,-Bstatic -ljpeg -Wl,-Bdynamic
>
> Of course, this assumes a gcc compiler, and I don't think the OS X
> linker understands the -Bstatic switch, so that would limit the
> portability of your .pro file.
>
Yes. I already did that, and it worked. Read above. :)
--Dave
--
[ signature omitted ]
Message 6 in thread
On Tuesday 12 December 2006 19:53, Dave Smith wrote:
> And that seems to have resolved them. I didn't really want to link to
> the system libjpeg.a, but oh well. Is that the recommended way to do it?
>
> Whatever the case, this has solved my problem. I was just hoping to link
> against Qt's jpeg lib, and not the system lib.
By default, configure detects whether libjpeg is present on the system and
uses it. If you want to always build libjpeg into Qt, then you should run
configure with -qt-libjpeg.
--
[ signature omitted ]