PDA

View Full Version : Portability of Dynamic / Static version of my own application



Selven
13th April 2012, 23:48
Hello,

I'm trying to make my application portable.

So i want 4 versions :
- 1 static 64 bits
- 1 dynamic 64 bits
And both in 32 bits too.

First, i will do the first group, in 64 bits.


===== DYNAMIC VERSION =====

My program is by default, compiled in dynamic i guess. So, i put the binary file on another computer and trying to run it :

error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory
So i tried to copy the file libQtGui.so.4 from the lib directory, into the folder which contains the binary file. It's the same issue. So I think i forgot something but dunno what.


===== STATIC VERSION =====
I download the library source, and I do these commands :

./configure -static -release -prefix /usr/local/Trolltech/Qt-4.8.1_static
gmake
gmake install

I add manually the static qmake on Qt Creator, i delete the .pro.user and i restart Qt Creator. Now i select the static version of compiler and i compile my application.
In dynamic version, its size is 640ko and in static : 18 mo. I think the static linking worked successfully.

There is a graphical issue when i starts the program.
When it starts, it ask you to select a folder.
2 screens, one in dynamic and the other, in static :
7585 7586

After that, the program in static version is very ugly... A slider is missing on the IHM. It is strange..

Note : I read somewhere that if I use Thread, it's not useful to make static version because I have to keep one library file, but i don't remember its name.

I tried to start the static version on another computer, and i had an error :

./Tairona-visue: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./Tairona-visue)
But the libc6 is installed in this system, and the distribution is fully up to date...

Thanks in advance for your help, and sorry for my bad english !

shahid.pk
14th April 2012, 01:52
i can give you a hint on the first problem.the dynamic build that you have will need a compiler dll file too if mingGw compiler you will need something like mingdll-4 and for visual studio its something like ms something.so a compiler dll file and the Qt module dll that you have used in your application.

wysota
14th April 2012, 09:24
So i tried to copy the file libQtGui.so.4 from the lib directory, into the folder which contains the binary file. It's the same issue. So I think i forgot something but dunno what.
You forgot that you're on Linux and not Windows. Linux doesn't search for libraries in the current directory.


There is a graphical issue when i starts the program.
When it starts, it ask you to select a folder.
2 screens, one in dynamic and the other, in static :
7585 7586

After that, the program in static version is very ugly...
It is because you didn't link widget style plugins against your static app. Even if you do there is a good chance someone uses a custom widget style you won't be able to load into your static app anyway.


Note : I read somewhere that if I use Thread, it's not useful to make static version because I have to keep one library file, but i don't remember its name.

That's not true, threads have nothing to do with how your application needs to be compliled. Qt is multithreaded regardless if you use threads or not.

Selven
14th April 2012, 14:31
So, what is the directive to add to the $PATH, in order that linux searches in the current directory ?
I don't find it on the documentation and on the internet, when i searches my error return, i have only some terminal commands for install Qt libraries... That's not what I want..

For graphical issue:
If i understand, you recommend to compile only in dynamic ? Because if someone uses a custom widget style, there can be a problem...

About threads :
Okay, so i heards something wrong... Thanks for your correction !

Thanks for your responses,

wysota
14th April 2012, 14:45
So, what is the directive to add to the $PATH, in order that linux searches in the current directory ?
You can't fix that with $PATH, it's not Windows. You can use $LD_LIBRARY_PATH instead or just make your app LSB compliant so that it can run on any LSB system (like most Linux distros today).


For graphical issue:
If i understand, you recommend to compile only in dynamic ?
No, that's not what I meant. I meant that when you build your app statically, you need to do some extra steps to make things work. However nowadays it's hard to find a Linux system without Qt installed so it might be easiest to just build dynamically and ask your users to install Qt using their distro's package manager.