PDA

View Full Version : Building Qt statically



mynewaccc1
22nd March 2016, 09:34
Hi,
Kind of a newb question. Does building Qt statically ensure me it will run on ANY machine (giving it is the correct platform), without any environment/libs/etc' dependencies, Is is guaranteed to run on any freshly installed Linux?

Thanks.

anda_skoa
22nd March 2016, 10:22
Statically linking an application means that the library code used by the application is part of the application executable.

But that library could have also used libraries, so you need to statically link those as well. And so forth.
Some application or library code might load plugins at runtime, so the code to do that needs to be replaced with build-time link code.

But yes, if you statically link everything down to including libc you could essentially run the application on top of just the OS kernel.

In general lots of work for little gain.

Cheers,
_

mynewaccc1
22nd March 2016, 10:33
Statically linking an application means that the library code used by the application is part of the application executable.

But that library could have also used libraries, so you need to statically link those as well. And so forth.
Some application or library code might load plugins at runtime, so the code to do that needs to be replaced with build-time link code.

But yes, if you statically link everything down to including libc you could essentially run the application on top of just the OS kernel.

In general lots of work for little gain.

Cheers,
_

So what would be the best way of building a Qt application in such a way that a freshly installed with no internet connection, would be able to run this?

anda_skoa
22nd March 2016, 11:22
It depends on what you expect the target system to have already and which things you don't.

Then you bundle all the things you don't expect to be present and let your start script set e.g. LD_LIBRARY_PATH so that your libraries can be found by the runtime linker.

Cheers,
_