PDA

View Full Version : Deploying Qt Application under Linux



addu
23rd October 2009, 12:58
I had never deployed Qt application under linux..

My application i have used following module additionally

1) Qt network

2) Qt webkit

3) Qt Sql

I tried with application distribution with following libs along with my application

1) Application folder

1) application
2) libQtGui.so.4
3) libQtCore.so.4
4) libQtNetwok.so.4
5) libQtxml.so.4
6) libQtWebkit.so.4
7)libQtSql.so.4
8) sql drivers folder

But i am getting error message ../Maxxtel could not able to run.

please help me

Thanks

Yuvaraj R

TMan
23rd October 2009, 14:27
In general, there are two "good" options for this.

1) Use dynamic linking and let people install Qt form their linux software repositories, or
2) Use static linking so people don't need any additional libs (except libc and such obviously)

Which of these are you trying to do? Furthermore, it may help if you post the real error message instead of "could not able to run".

addu
24th October 2009, 06:16
till now i have been using dyanamic method under windows

In linux i want use static method .

please explain me about static method.

how do we distribute the application using static method ?

Thanks

Yuvaraj R

nightghost
24th October 2009, 09:23
Did you read http://qt.nokia.com/doc/4.5/deployment-x11.html and maybe http://qt.nokia.com/doc/4.5/qt-conf.html?




But i am getting error message ../Maxxtel could not able to run.

What error message? Please help us and give us real example :-)

squidge
24th October 2009, 10:55
You can't put dynamic libs in the same directory as the executable under Linux unless you modify the library search path, and even then, a simple library called libQtGui.so.4 will not be used without a symlink to specify the current library version (usually created by installing the library into the system library dir). This will be why you are getting this error. Under Windows it always searches the application path first.

Its much easier to just add the Qt dependancy to your package and distribute that. When people install your app it will automatically install Qt if necessary (which is the preferred way of distributing Linux apps). If you don't want to package your application, then you must use static linking, but this requires you to rebuild Qt and pay Nokia money unless your app is open source.

addu
24th October 2009, 13:11
Hi

I opened nighthost mentioned links , but i didn't opned..

How do add Qt dependencies for my package distibution ..

please provide me related links

Thanks

Yuvaraj R

squidge
24th October 2009, 13:54
I think you should read this: http://en.wikipedia.org/wiki/Package_management_system for better understanding.

ChrisW67
25th October 2009, 03:52
Addu,

Your initial problem with failing to load the program could be helped by some of these:

Reading the man page for ldd (1) and running it on your executable.
Reading the man page for ld.so (8) particularly about the environment variable LD_LIBRARY_PATH and also when it is ignored.
Using a script to wrap your executable and adjust with the LD_LIBRARY_PATH before handling off to your executable.
Building a statically linked executable (but read and understand your Qt License first).


Without being able to read minds we cannot help you with packaging your product. You need to tell us:

Whether you can distribute source or the product is binary only. If you can distribute source, and the end-user can build it, then you may only need to put dependency info in a Readme file. If binary only you need to package using a tool that the target OS can understand so the user does not have to guess.
What your target Linux audience is: tech savvy, not tech savvy, people who normally use Windows, paying or non-paying users etc.
What distros they are running. Packaging for Ubuntu (Debian), Redhat (CentOS), Gentoo or Slackware is different. Google for dpkg, RPM, ebuild, ...


It almost always helps to tell people what you have already tried, provide exact error messages if that's what you are asking about, provide that actual code of a minimal program that reproduces the fault if possible, explain what you expected to happen etc. Put some effort into asking smart questions and you'll get much more helpful answers.

schnitzel
25th October 2009, 05:38
I'm not sure whether this is the best solution, but I was able to deploy on linux (ubuntu 9.04) like this:

create a file myapp.conf in /etc/ld.so.conf.d/
Inside that myapp.conf file, you should list the directory where your application plus libs reside.
For example myapp.conf will contain a single line:
/home/schnitzel/myapp

I believe you have to then run the command ldconfig. This method is way better than futzing around with LD_LIBRARY_PATH.

My app uses dynamic linking so my application folder contains only qt core, gui libs, two third party libs and some plugins.

I still have to wrap my head around creating a package in order to make the install procedure as simple as possible.

Is it possible to create an ubuntu package with only binaries in it?

ChrisW67
25th October 2009, 09:17
This method is way better than futzing around with LD_LIBRARY_PATH.

This method affects the system globally and does leave you open to dynamically linking to the first libQtCore.so.4 (a symlink to a specific version like libQtCore.so.4.5.2) the system finds in the ld.so search path. Normally this is not a problem but can be if, for example, you rely on a fix Qt in 4.5.3 and the first Qt that is found is a Qt 4.5.0 because that's in the path earlier. Conversely, your version might be found first and break someone else's app. Binaries I have built tend to link by name to libQtCore.so.4 (i.e. any Qt4 vers) and not libQtCore.so.4.5.2, but there is probably a way to force this if a specific version is required.

The script approach makes the change local to your application. For example this is the wrapper for the Google Earth app on my machine:


#!/bin/sh
cd "/opt/googleearth"
if [ -n "." ] ; then
if [ "${LD_LIBRARY_PATH+set}" = "set" ] ; then
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:."
else
export LD_LIBRARY_PATH="."
fi
fi
exec ./googleearth "$@"

schnitzel
25th October 2009, 22:42
This method affects the system globally and does leave you open to dynamically linking to the first libQtCore.so.4 (a symlink to a specific version like libQtCore.so.4.5.2) the system finds in the ld.so search path. Normally this is not a problem but can be if, for example, you rely on a fix Qt in 4.5.3 and the first Qt that is found is a Qt 4.5.0 because that's in the path earlier. Conversely, your version might be found first and break someone else's app. Binaries I have built tend to link by name to libQtCore.so.4 (i.e. any Qt4 vers) and not libQtCore.so.4.5.2, but there is probably a way to force this if a specific version is required.

The script approach makes the change local to your application. For example this is the wrapper for the Google Earth app on my machine:


#!/bin/sh
cd "/opt/googleearth"
if [ -n "." ] ; then
if [ "${LD_LIBRARY_PATH+set}" = "set" ] ; then
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:."
else
export LD_LIBRARY_PATH="."
fi
fi
exec ./googleearth "$@"


I will try your approach - somehow I was a bit ignorant and thinking the app.conf file would only be relevant to my app.

addu
26th October 2009, 06:15
Hi

i referred the ldd and ld.so commands

In Qt unstalled systems i ran the following command.

ldd ./my application

it gave me

libQtCore.so.4 not fond
libQtGui.so.4 not found

But i have plaed both libs in my application folder.

Now i ran ./configure -static -prefix /qt instaliton path

then i have used make command

Then i went ot lib of Qt .. there i have the command make install..

still i didn't replace old libs , once i replaced and update here


Thanks


Yuvaraj R

squidge
26th October 2009, 08:19
As stated above, unless the application directory is contained in LD_LIBRARY_PATH, then its not going to find the libraries in the application dir. You shouldn't be messing with LD_LIBRARY_PATH either, but instead package your application so the installer will automatically install Qt if its not there already. Why include 10MB of libraries if you don't have to?

addu
27th October 2009, 04:41
Thanks for your reply

I used libs path in my application. I got solved issues regarding qt libs

Now new issues has been raised

It is showing Glibc _2.4 not found


Then i installed glibc_2.7 ,but i am getting same error.. is i have
install same version ?

Thanks

Yuvaraj R

MaikoID
30th June 2010, 19:55
Same erro here.

I'm using Kubuntu 10.04 to develop and a fresh install of Kubuntu 8.04 to execute but it falls.

if I use Qt static libraries:


./bcFinal
./bcFinal: /lib/tls/i686/cmov/libc.so.6: version `GLIBC_2.9' not found (required by ./bcFinal)
./bcFinal: /lib/tls/i686/cmov/libc.so.6: version `GLIBC_2.11' not found (required by ./bcFinal)


if I use Qt shared libraries:


Segmentation fault.


the command


$ ldd ./bcFinal
linux-gate.so.1 => (0xb7f7f000)
libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0xb786d000)
libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0xb76f9000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb76e0000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb75ed000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb75c8000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb75bd000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb746e000)
libaudio.so.2 => /usr/lib/libaudio.so.2 (0xb7458000)
libXt.so.6 => /usr/lib/libXt.so.6 (0xb7406000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0xb73e3000)
libSM.so.6 => /usr/lib/libSM.so.6 (0xb73db000)
libICE.so.6 => /usr/lib/libICE.so.6 (0xb73c3000)
libz.so.1 => /usr/lib/libz.so.1 (0xb73ae000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb73a9000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb739f000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb72ee000)
libXi.so.6 => /usr/lib/libXi.so.6 (0xb72e6000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0xb72de000)
libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0xb72d8000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0xb72d3000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0xb72c9000)
libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0xb72c6000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb7259000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb722f000)
libXext.so.6 => /usr/lib/libXext.so.6 (0xb7221000)
libX11.so.6 => /usr/lib/libX11.so.6 (0xb713a000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7135000)
/lib/ld-linux.so.2 (0xb7f80000)
libpcre.so.3 => /usr/lib/libpcre.so.3 (0xb710e000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0xb70ed000)
libXau.so.6 => /usr/lib/libXau.so.6 (0xb70ea000)
libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0 (0xb70e7000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb70cf000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb70ca000)



What I can do to solve this ?

SixDegrees
30th June 2010, 21:55
Linux, like all operating systems, does NOT guarantee backward compatibility. If you developed under Kubuntu 10.04, your app is NOT going to run under Kubuntu 8.04 or any other version earlier than 10.04. Your application fails because the C runtime version it was built against doesn't exist on your test machine.

MaikoID
1st July 2010, 13:24
Thanks for the answer.

What Qt in static mode can I install in kubuntu 8.04 to compile and excute my app ? Qt 3 or Qt 4 ? Where can I download ?

Thành Viên Mới
27th November 2010, 04:40
which libs gcc download ?, can you help me