PDA

View Full Version : run qt program on linux



Anenja
4th April 2013, 19:06
Hello together,

first, sry for this stupid question but i tried to solve it with google and the search function but wasnt able to find s.th ....

I wanna run a qt program (nothing special on a stand alone linux machine).
Machine 1: ubuntu 12.04 qt 4.8 compiled the program and it works well. (dynamic linking so i need to put the qt libs near the executeable file that the OS can find them.)
Machine2: ubuntu 12.04 (no qt installed) wont run the program cause i need to give the program some libs or? On Windows i just put the neccessary qt dll´s in a path the .exe can find them and then the program runs on windows. But i am a newbie on linux, so i looked for qt .so files but dont find them...

So the question is, how can i use a program which is compiled on ubuntu on another linux machine without installing qt?

TIA for ur help!
Anenja

BalaQT
5th April 2013, 07:59
Hi anenja,

Just check the docs,
http://qt-project.org/doc/qt-4.8/deployment-x11.html


But i am a newbie on linux, so i looked for qt .so files but dont find them
You didnt mention the Qt version you are using.

If you are using Qt5.0, you can find the libs under,
/home/noufal/Qt5.0.1/5.0.1/gcc/lib/


So the question is, how can i use a program which is compiled on ubuntu on another linux machine without installing qt?
You need all the required lib files. For ex: if you are using QtGui then you need QtGui lib file.
You need to copy all the required lib files inside the application dir.

In your target system, just try to run the application using terminal
ex: ./myApp
Application will complain about the required lib files. Just copy the libs in the app dir.

Hope it helps,
Bala

Anenja
5th April 2013, 13:23
Hi,

thanks for ur reply. i Give it a try this evening and post the result.
btw. qt version 4.8.

Thanks!

wysota
5th April 2013, 13:41
Google for LD_LIBRARY_PATH and/or "rpath linker option".

anda_skoa
5th April 2013, 13:52
Machine 1: ubuntu 12.04 qt 4.8 compiled the program and it works well. (dynamic linking so i need to put the qt libs near the executeable file that the OS can find them.)

Obviously the OS finds the libs installed in the system wide location



Machine2: ubuntu 12.04 (no qt installed) wont run the program cause i need to give the program some libs or?

The most common thing is to ship the Qt libraries with the program, e.g. putting them in the same directory as the executable, and have a starter script that sets LD_LIBRARY_PATH to include that directory.

LD_LIBRARY_PATH is an environment variable that works similar to PATH, but on libraries instead of executables.
It is usually unset (not set at all), so libraries are only searched for in system locations. It can be set to a colon separate list of directories that are then searched before falling back to system locations.

For example: if you had a program installed in /opt/myprogram/bin and some libraries in the same directory, then
cd /opt/myprogram/bin
export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH
./myprogram

would try to find libraries needed by myprogram first in /opt/myprogram/bin, then in any other path that was in LD_LIBRARY_PATH before the new export and finally in all system locations.

Cheers,
_

Anenja
8th April 2013, 12:19
Thanks for all the help!

Sorry for the late answer, i have not much time to try all ur hints.
It works like u all said, if i put the libs to the executeable - the LD_LIBRARY_PATH is really nice to know and i will google for it.


Wish u all a nice day.