PDA

View Full Version : libqjpeg troubles



TheRonin
25th August 2006, 14:15
My application loads jpeg images with Qimage. Things work fine when compiling with both debug and release, however when i move the app to a computer that doesn't have Qt installed the application won't load the image. I tried adding QTPLUGIN += qjpeg to the .pro file and used Q_IMPORT_PLUGIN(qjpeg) in my code. However, when i add this i get the following compiler error:


P:/QT/MinGW-gcc-3.4.2/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[1]: Entering directory `H:/workspace/prototype/planner'
g++ -c -g -g -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
g++ -DQT_DLL -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB
g++ -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
g++ -I"P:/QT/qt-win-4.1.4-mingw-20060823/include/QtCore"
g++ -I"P:/QT/qt-win-4.1.4-mingw-20060823/include/QtNetwork"
g++ -I"P:/QT/qt-win-4.1.4-mingw-20060823/include/QtGui"
g++ -I"P:/QT/qt-win-4.1.4-mingw-20060823/include/QtXml"
g++ -I"P:/QT/qt-win-4.1.4-mingw-20060823/include" -I"."
g++ -I"P:/QT/qt-win-4.1.4-mingw-20060823/include/ActiveQt" -I"debug"
g++ -I"." -I"p:\QT\qt-win-4.1.4-mingw-20060823\mkspecs\win32-g++" -o
g++ debug\mapdrawwidget.o ..\mapdraw\mapdrawwidget.cpp -mthreads
g++ -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import
g++ -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,windows -o
g++ "debug\planner.exe" object_script.planner.Debug
g++ -L"p:\QT\qt-win-4.1.4-mingw-20060823\lib" -lmingw32 -lqtmaind
g++ -lQtXmld4 -lQtGuid4 -lQtNetworkd4 -lQtCored4
g++ -LP:\QT\qt-win-4.1.4-mingw-20060823\plugins/imageformats/ -lqjpegd
P:\QT\MinGW-20060823\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\ mingw32\bin\ld.exe: cannot find -lqjpegd
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug\planner.exe] Error 1
mingw32-make.exe[1]: Leaving directory `H:/workspace/prototype/planner'
P:\QT\MinGW-gcc-3.4.2\bin\mingw32-make.exe: *** [debug] Error 2

I'm using mingw32 3.4.2 with Qt 4.1.4 and i've compiled it to use Qt's own jpeg library instead of the hosts native jpeg support.

Thanks in advance!

jacek
25th August 2006, 14:37
cannot find -lqjpegd
It looks like you don't have a debug version of QJPEG plugin.

TheRonin
25th August 2006, 15:10
Iindeed, the compiler doesn't seem to find the release version either. I have qjpeg1.dll and qjpegd1.dll in my Qt/plugins/imageformats/ folder though. Aren't those the right ones? If not, where would i find the correct ones?

jacek
25th August 2006, 15:17
I have qjpeg1.dll and qjpegd1.dll in my Qt/plugins/imageformats/ folder though. Aren't those the right ones?
Yes, but for linking you need libqjpeg.a or libqjpegd.a. Do you have these files somewhere?

Anyway, if you want to use QJPEG plugin on a system where Qt isn't installed, just create a imageformats subdirectory in the directory where your executable is and place qjpeg1.dll there.

TheRonin
25th August 2006, 15:44
Well i have libqjpeg1.a and libqjpegd1.a in the same imageformats directory as the dlls.

Thanks for the tip with the dll's in the executable directory. Works devinely. If and when i get the compilation to work with libqjpeg, will i still need to distribute the dll's with my app? if so, what do i gain from using the qjpeg plugin?

jacek
25th August 2006, 16:36
Well i have libqjpeg1.a and libqjpegd1.a in the same imageformats directory as the dlls.
I guess that the problem is in that "1" at the end.


If and when i get the compilation to work with libqjpeg, will i still need to distribute the dll's with my app? if so, what do i gain from using the qjpeg plugin?
"static plugins" mechanism was intended for use with static linking.

With dynamic linking, you will have to distribute DLLs and your application won't start without them. If you were using plugins, it would start --- just missing plugins wouldn't be available.

Also it might be useful for troubleshooting "plugin not loaded" problems, since you link against the plugin, instead of loading it at runtime.

TheRonin
25th August 2006, 16:48
Ok thanks!

As far as the 1 at the end of the filename is concerned, that's Qt's doing! When i try to remove it the compiler whines about methods and functions in the plugin.

But if i understand you correctly then the solution is that i haven't built qt for static linking so the plugins aren't either. If i were to configure qt for static linking i'm confident the plugin dll's will get the proper names and my troubles will go away. I'm thinking that the error was caused by me loading a plugin for static linking when i was linking dynamically.

That's my theory at this point, but please let me know if i'm wrong :o