[Qt-interest] LGPL and static linking
Clinton Stimpson
clinton at elemtech.com
Tue Dec 1 18:02:26 CET 2009
On Dec 1, 2009, at 7:54 AM, Paul Floyd wrote:
> Quoting Konrad Rosenbaum <konrad at silmor.de>:
>
>
>> out of curiosity: why do people prefer static linking? Why do you
>> consider
>> dynamic linking bad?
>>
>> Maybe this discussion helps to enlighten all of us... ;-)
>
> As far as I'm aware there are two main advantages to static linking.
>
> 1) Size [files and memory footprint]. The statically linked app
> only extacts
> those functions and data that it requires from static libraries,
> whilst dynamic
> libraries have to keep everything. When you have more than one
> application using
> the library/ies, then dynamic linking can have an advantage.
> Additionally,
> linking options like lazyload can reduce the memory footprint.
Its also a benefit if the user is going to install more than one app
that uses a system wide Qt installation (even if those apps don't
come from one entity).
>
> 2) Speed. Dynamic libs get compiled with position independent code
> (pic). This
> is generally slower, as global data and functions need to 'bounce'
> off an
> offset. Code in static libs can access globals and call functions
> directly.
How about avoiding those indirections for internal functions by using
gcc's visibility stuff?
And for those functions which are part of the API, and where the
overhead matters, just inline them.
Clint
More information about the Qt-interest-old
mailing list