PDA

View Full Version : Qt 5 - Linux deployment - can you dynamically link dependencies?



te777
9th March 2013, 17:33
I have a Linux Qt 5 app I'm trying to deploy on other Linux systems. I'm using VirtualBox machines develop and test. My app runs with the dependencies on the devoper machine, but not on a non-developer test machine. I have a script which loads the dependencies identified by using the ldd command. Are there any dependencies not listed by the ldd command? I'm trying to dynamically link the dependencies. Is that possible? Or do I have to configure and build from the source code with the static option? Any help would be appreciated. Thanks.

wysota
9th March 2013, 18:58
How does the script "load" dependencies?

te777
9th March 2013, 19:39
Here's the script:

#!/bin/sh

if [ `getconf LONG_BIT` = "64" ]
then
LIBS=./data/libs_64
BIN=./data/bin/Lottery_64
else
LIBS=./data/libs_32
BIN=./data/bin/Lottery_32
fi

# Run your app
export LD_LIBRARY_PATH=$LIBS:"$LD_LIBRARY_PATH"
$BIN $@


It's for both 32 bit and 64 bit deployment. My test machine is 32 bit, so the dependencies are in libs_32. The script works on the deveopment machine (32 bit), but nothing happens when I execute the script on the test machine. The app is Lottery_32 and is in the appropriate folder.

wysota
9th March 2013, 21:19
This doesn't "load" anything. It just sets library search path. If you add Qt libs (and their dependencies) to one of those paths, it will be ok.

te777
9th March 2013, 21:27
How do you do that? Do I have to install Qt 5 on the test machine? Or copy the lib directory to the test machine? I'm trying to enable deployment any 32-bit Linux machine by supplying the dependencies, without having Qt 5 having to be installed on the deployment machine. Here are the dependencies I have in the libs_32 folder:

linux-gate.so.1 => (0xb77c1000) (Not in folder)
libQt5Widgets.so.5 => /home/tom/Qt5.0.0/5.0.0/gcc/lib/libQt5Widgets.so.5 (0xb7197000)
libQt5Gui.so.5 => /home/tom/Qt5.0.0/5.0.0/gcc/lib/libQt5Gui.so.5 (0xb6d81000)
libQt5Core.so.5 => /home/tom/Qt5.0.0/5.0.0/gcc/lib/libQt5Core.so.5 (0xb6936000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb6837000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb6819000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb666f000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb6654000)
libgobject-2.0.so.0 => /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 (0xb6603000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb6507000)
libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb63d1000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb63a5000)
libGL.so.1 => /usr/lib/i386-linux-gnu/mesa/libGL.so.1 (0xb6347000)
libicui18n.so.49 => /home/tom/Qt5.0.0/5.0.0/gcc/lib/libicui18n.so.49 (0xb612e000)
libicuuc.so.49 => /home/tom/Qt5.0.0/5.0.0/gcc/lib/libicuuc.so.49 (0xb5fb4000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb5faf000)
libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 (0xb5fac000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb5fa3000)
/lib/ld-linux.so.2 (0xb77c2000)
libffi.so.6 => /usr/lib/i386-linux-gnu/libffi.so.6 (0xb5f9b000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb5f5b000)
libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb5f39000)
libglapi.so.0 => /usr/lib/i386-linux-gnu/libglapi.so.0 (0xb5f23000)
libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xb5f11000)
libXdamage.so.1 => /usr/lib/i386-linux-gnu/libXdamage.so.1 (0xb5f0c000)
libXfixes.so.3 => /usr/lib/i386-linux-gnu/libXfixes.so.3 (0xb5f05000)
libX11-xcb.so.1 => /usr/lib/i386-linux-gnu/libX11-xcb.so.1 (0xb5f02000)
libxcb-glx.so.0 => /usr/lib/i386-linux-gnu/libxcb-glx.so.0 (0xb5eea000)
libXxf86vm.so.1 => /usr/lib/i386-linux-gnu/libXxf86vm.so.1 (0xb5ee4000)
libdrm.so.2 => /usr/lib/i386-linux-gnu/libdrm.so.2 (0xb5ed6000)
libicudata.so.49 => /home/tom/Qt5.0.0/5.0.0/gcc/lib/libicudata.so.49 (0xb4db5000)
libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb4db1000)
libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb4daa000)

wysota
9th March 2013, 21:54
Qt is a set of regular C++ libraries. It works exactly the same as any other library and is governed by exactly the same rules. So all that applies to any other library applies to Qt as well.

anda_skoa
10th March 2013, 11:10
Which output do you get for ldd when you setup LD_LIRBARY_PATH on the deployment machine?

e.g. something like



# Run your app
export LD_LIBRARY_PATH=$LIBS:"$LD_LIBRARY_PATH"
ldd $BIN > /tmp/ldd-output.txt
$BIN $@


Cheers,
_

te777
10th March 2013, 11:25
Here's what I get using the ldd addition to the script on the deployment machine:

linux-gate.so.1 => (0xb77b7000)
libQt5Widgets.so.5 => ./data/libs_32/libQt5Widgets.so.5 (0xb718d000)
libQt5Gui.so.5 => ./data/libs_32/libQt5Gui.so.5 (0xb6d76000)
libQt5Core.so.5 => ./data/libs_32/libQt5Core.so.5 (0xb692c000)
libstdc++.so.6 => ./data/libs_32/libstdc++.so.6 (0xb6843000)
libgcc_s.so.1 => ./data/libs_32/libgcc_s.so.1 (0xb6825000)
libc.so.6 => ./data/libs_32/libc.so.6 (0xb667b000)
libpthread.so.0 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libpthread.so.0 (0xb665f000)
libgobject-2.0.so.0 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libgobject-2.0.so.0 (0xb660f000)
libglib-2.0.so.0 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libglib-2.0.so.0 (0xb6513000)
libX11.so.6 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libX11.so.6 (0xb63dd000)
libm.so.6 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libm.so.6 (0xb63b0000)
libGL.so.1 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libGL.so.1 (0xb6352000)
libicui18n.so.49 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libicui18n.so.49 (0xb613a000)
libicuuc.so.49 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libicuuc.so.49 (0xb5fc0000)
libdl.so.2 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libdl.so.2 (0xb5fbb000)
libgthread-2.0.so.0 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libgthread-2.0.so.0 (0xb5fb7000)
librt.so.1 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/librt.so.1 (0xb5fae000)
/lib/ld-linux.so.2 (0xb77b8000)
libffi.so.6 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libffi.so.6 (0xb5fa7000)
libpcre.so.3 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libpcre.so.3 (0xb5f67000)
libxcb.so.1 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libxcb.so.1 (0xb5f44000)
libglapi.so.0 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libglapi.so.0 (0xb5f2e000)
libXext.so.6 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libXext.so.6 (0xb5f1c000)
libXdamage.so.1 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libXdamage.so.1 (0xb5f18000)
libXfixes.so.3 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libXfixes.so.3 (0xb5f11000)
libX11-xcb.so.1 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libX11-xcb.so.1 (0xb5f0e000)
libxcb-glx.so.0 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libxcb-glx.so.0 (0xb5ef5000)
libXxf86vm.so.1 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libXxf86vm.so.1 (0xb5eef000)
libdrm.so.2 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libdrm.so.2 (0xb5ee2000)
libicudata.so.49 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libicudata.so.49 (0xb4dc1000)
libXau.so.6 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libXau.so.6 (0xb4dbc000)
libXdmcp.so.6 => /home/tom/LotteryAnalyzerExpertQL_32bit/./data/libs_32/libXdmcp.so.6 (0xb4db5000)

wysota
10th March 2013, 11:47
So what exactly is the problem? It seems all dependencies are resolved.

Note that you will probably want to deploy some plugins as well.

te777
10th March 2013, 11:52
When i click on the script, I choose RUN, and nothing happens. I have the platforms folder in the binary directory. Are there any other plugins that I need?

wysota
10th March 2013, 12:05
"Nothing happens" is a bit vague description of a problem. Maybe you are using some relative paths in your program?

te777
10th March 2013, 12:36
The program doesn't execute or start. I'm using QStandardPaths::HomeLocation to create user files and QCoreApplication::applicationDirPath to initially find user files and copy them to HomeLocation. The program then uses HomeLocation to operate from, both input and output files. The GUI should still execute since I check in the program for existence of needed files. If the program is executing then I should get a GUI and a "Cannot find input file" message box.

wysota
10th March 2013, 13:29
The program doesn't execute or start.
How did you verify that?


If the program is executing then I should get a GUI and a "Cannot find input file" message box.
Not if it crashes before reaching this code.

te777
10th March 2013, 13:45
I tend to not think the program is crashing. The script works on the development machine where Qt 5 is installed. The program works correctly there in every way. I tend to think there is a dependency problem. Maybe I'm wrong. How do I verify if the program is executing at all?

wysota
10th March 2013, 15:03
Maybe I'm wrong. How do I verify if the program is executing at all?
One way would be to replace its main() function with something that returns a known error code and check in the script that the code returned is or is not equal to what you expect.

Something along the lines of

...

$BIN $@
if [ $? eq "42" ] ...

and


int main() { return 42; }

Another would be to intercept and log stderr of the script in a well known place.

te777
10th March 2013, 15:51
I installed Qt 5 on the test machine and the application works perfectly. So it is a dependency issue. Now just to figure out what else is needed.

wysota
10th March 2013, 15:56
Maybe this will help:

http://sourceforge.net/projects/recursive-ldd/