PDA

View Full Version : how to run Qt programs on non qt machine ?



aamer4yu
22nd January 2007, 05:15
I am working on Qt 4.2.2 Open source edition. I made a simple image reader like application which loads an image and does some processing. I compiled the code, and its fine on my machine.
The problem comes when I want to run the application on my friends machine which doesnt have Qt installed.The application does run, but when I try load an image, it says cannot load the image 'D:\......jpg'.
I also copied the Qt's bin directory files to my friends machine, but it deosnt help too :(

What am I missing to run Qt Application on other machine ??

e8johan
22nd January 2007, 07:38
The jpeg loading is handled by a Qt plugin. You need to ship this plugin with your application. I would recommend you to put it next to your executable and add a new directory to you plugin search path in your main function. Or you can compile the plugin into your application by making it static.

You can find out more about it here: http://doc.trolltech.com/4.2/plugins-howto.html .

aamer4yu
23rd January 2007, 05:16
thx,
i read the link.. and included the macro in my application, added QTPLUGIN in m y .pro file... but still I am getting linking error...
seems I am missing something..
can you elaborate a little on the steps...
thx

gri
23rd January 2007, 15:14
So what are your linker errors? Show the messages please.

aamer4yu
24th January 2007, 05:16
I am attaching a similar example from Image view of Qt Demo....
I have added

#include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qkrcodecs)
to the .cpp file
and

QTPLUGIN += qjpeg \
qgif \
qkrcodecs to the header file...

I get the error as..

Linking...
LINK : fatal error LNK1181: cannot open input file "qgif.lib"
Error executing link.exe.

Image Test.exe - 1 error(s), 0 warning(s)

what wrong am I doing ??

gri
24th January 2007, 11:40
The gif extension for Qt is not being compiled by default. To enable it you have to add "--qt-gif" to your configure commandline.

aamer4yu
24th January 2007, 12:00
how do i do that ?? can u explain ?
thx

gri
24th January 2007, 12:11
How did you compile your Qt version if you don't know how to configure it?

With gcc:

$QTDIR/configure.exe --qt-gif
make

With Visual Studio (OpenSource version with QtWin patch)

qconfigure.bat <compiler> --qt-gif
nmake

aamer4yu
24th January 2007, 12:26
ya i had compiled my Qt with the QtWin patch from here (http://qtnode.net/wiki/Qt4_with_Visual_Studio).

with the parameter qconfigure.bat msvc2005
and i had read that by default static version are built...

will i have to rebuild Qt with static option to enable importing the plugins ??
Note : On my machine I have no problem running the program, its when I have to run the program on my friends machine, I get the plugin problem :(

I feel like a kid when it comes to makefiles and static/dynamic builds... i nver bothered to dig deep in it, just use the IDE's. Is there any link to know how to build dynamic/static programs, what are the various options, etc ??

And what option should i keep for jpg and bmp formats ??

Thx for ur help... and hope u can give some more time to me :D

gri
24th January 2007, 12:37
You have to rebuild the libraries. If you want to use a static Qt version, you'll have to type "qconfigure.bat msvc2005 --qt-gif -static". Otherwise without "-static" (maybe "--static").

If your program links on your computer but no images can be shown on your friends machine you probably forgot to deliver the "plugins/imageformats" dlls to him. You should read Deploying Qt Applications (http://doc.trolltech.com/4.2/deployment.html) for that.

If it does not load the imageformats like you want you have to call "QCoreApplication::addLibraryPath()" and set the path where the imageformats are.

aamer4yu
24th January 2007, 12:44
is ther a way to check if my build is a static one or not ?? and what image formats are supported ?
and also does it have the plugins required ??

in here (http://qtnode.net/wiki/Qt4_with_Visual_Studio) it is written that
Take note of any options that you are interested in. Note that by default, static and debug versions of the library are built - this is usually the appropriate choice for most developers.

rebuilding Qt takes a lot of time... so wanna avoid it..

I will try the solutions u gave...i guess i have problem with deploying, bec on my machine, when i run the program, i am able to load the images and edit them..

Thx again

gri
24th January 2007, 12:58
is ther a way to check if my build is a static one or not ?? and what image formats are supported ?
and also does it have the plugins required ??
You can check that. If you have a QtCore4.dll in $QTDIR/bin it seems to be a dynamic linked version. The supported imageformats depend on which one you have built. The normal Qt distribution supports JPEG, PNG, SVG and GIF (reading, which is disabled by default).

Yes, rebuilding takes a little bit of your time. But you don't do that every day so take the time and configure your environment like you need it. Compiling whole Qt takes about 40 minutes to one hour on my computer.

aamer4yu
25th January 2007, 05:36
thanks...

is there some boook or site from where I can learn these building things ?? till now I have been using IDE's and not much bothereed whats going on at the back...

it wud be nice if I get some link to read from.. all this static/dynamic building, deploying... understanding how .lib and .dll work... how to use .lib , .dll with static and dynamic build..etc... :confused:
thx

gri
25th January 2007, 09:10
I don't know a book, maybe someone else ...

For me Qt's .pro files are self-explanatory and if I miss something, qmake's documentation (also available in the assistant) helps.
Building itself is like on every make based system, not much commands. "make --help" could help you. Also "qconfigure --help" may help you to see with which options you could build Qt.

nguahoang205
11th July 2012, 04:03
Hi everyone,

I am a new Qt programmer
I have a Qt application, I build and run on my machine (Qt installed) is OK, but I copy it to other machine non installed Qt, it do not run.
I need to know this method very much. Can anyone help me?

Thanks.
nguahoang

wysota
11th July 2012, 08:38
Deploying Qt Applications