PDA

View Full Version : Jpeg support or ordeal is on the go



Astrologer
26th April 2010, 13:48
Hi there. I know that this topic has been brought up dozen of times, but I am still having trouble. I need to distribute my application to another computer. And I want to have JPEG support.

here .pro file:



CONFIG += static
TARGET = QKml
QTPLUGIN+= qjpeg
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp \
kml.cpp \
Geodesic.cpp \
JPG.cpp
HEADERS += mainwindow.h \
kml.h \
Geodesic.hpp \
Constants.hpp \
JPG.h
FORMS += mainwindow.ui


Here my main.cpp file:


#include <QtGui/QApplication>
#include "mainwindow.h"

#include <QtPlugin>

Q_IMPORT_PLUGIN(qjpeg)

int main(int argc, char *argv[])
{
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("Windows-1251"));

QStringList list_path;
QDir dir = QDir(qApp->applicationDirPath()+"/plugins/");
list_path << dir.absolutePath () << qApp->libraryPaths ();
qApp->setLibraryPaths( list_path );

QApplication a(argc, argv);
a.setLibraryPaths(list_path);
MainWindow w;
w.show();
return a.exec();
}

I'm trying to compile it as "release".
And it doesn't want to be compiled. The error is: "collect2: ld returned 1 exit status". In release folder where .exe is located I have "imageformats" folder with dlls and ".a" files. Can somebody help? Thank you so much in advance.

Lykurg
26th April 2010, 14:08
Forget about all your plugin stuff. Simply build the plugin and put the dll along side your application when shipping it. Qt will find the plugin by itself.

borisbn
26th April 2010, 14:57
By the way, do not use qApp macro before creating an instance: QApplication a(argc, argv);

Astrologer
26th April 2010, 18:30
Ok, I will not use "plugin stuff" and qApp macro, whatever it means, but can you be more specific about how? What do you mean by simply build my plugin? I don't use my own I just need "jpeg" to function in my application. Have I got to just put qjpeg4.dll in folder where .exe is located? (I tried and to no avail). What am I to do to make that work? Any workable example will be of help.

Lykurg
26th April 2010, 19:47
have a look at the documentation on how to deploy an application. On the bottom you find how to deal with Qt plugins. For building the jpeg plugin also look at the documentation. There is a howto. Just go in the source tree of Qt to the jpeg directory and build the plugin.

If the documentation is not enough for you, search the forum. There are a lot of topics about your problem.

Astrologer
26th April 2010, 20:28
Thank you. So, as far as I understand, there is no need in manipulating with Q_IMPORT or whatever. So I will try placing "imageformats" folder in my .exe folder tommorow with dll's inside. Should it contain "a" files? You mentioned a lot of topics, but I haven't stumbled across a single one which can give a tangible answer as to the error I keep receiving. And, frankly, I don't understand what it means to "compile statically". Do I have to rebuild QT with another compiling parameters?

Lykurg
26th April 2010, 21:25
Try it and see if it works. The error just indicates, that a library could not be found. But without more information one can't tell more.

Astrologer
27th April 2010, 08:08
It worked. I put "imageformats" folder into folder with executable and used release compilation. Thank you all, guys!

FoleyX90
19th May 2010, 15:28
Simply create a subdirectory in the same directory as your application. In the subdirectory, include qjpeg4.dll