[Development] Use static qt libraries

song.7.liu at nokia.com song.7.liu at nokia.com
Mon Jul 23 16:39:16 CEST 2012


OK, based on my current understanding, do you mean that:
I still need to build all of the current qt modules as static objects, which can be done by OPTS += -static or by other way ?

Thanks,
Song

-----Original Message-----
From: Storm-Olsen Marius (Nokia-MP/Austin) 
Sent: Monday, July 23, 2012 10:35 PM
To: Liu Song.7 (Nokia-MP/Beijing)
Cc: development at qt-project.org
Subject: RE: [Development] Use static qt libraries
Importance: High

No, you will need to link it all at once, since an .so is considered a final product.

You might be able to mess around with a qt5-massive-library.pro, which include()s all the module .pro files you want in the final library.
It's unknown how much tweaking you will need to achieve this final all-in-one module though. This is uncharted territory.

(Btw, with GCC you _can_ do
    gcc -shared qt5.so -Wl,--whole-archive lib1.a lib2.a lib3.a -Wl,--no-whole-archive but I have no idea if the end result would be usable in Qt's case. I doubt it.)

--
.marius


> -----Original Message-----
> From: Liu Song.7 (Nokia-MP/Beijing)
> Sent: Monday, July 23, 2012 9:16 AM
> To: Storm-Olsen Marius (Nokia-MP/Austin)
> Cc: development at qt-project.org
> Subject: RE: [Development] Use static qt libraries
> 
> Thanks for help. Is there any tool to link all of the separate shared libraries
> into one single shared library (libqt5.so) ?
> 
> Thanks,
> Song
> 
> -----Original Message-----
> From: Storm-Olsen Marius (Nokia-MP/Austin)
> Sent: Monday, July 23, 2012 10:12 PM
> To: Liu Song.7 (Nokia-MP/Beijing)
> Cc: development at qt-project.org
> Subject: Re: [Development] Use static qt libraries
> Importance: High
> 
> On 23/07/2012 08:56, ext song.7.liu at nokia.com wrote:
> > Hi,
> >
> > To use the static qt libraries, now I can build out all the
> > libQtCore.a , libQtGui.a , libQtWidgets.a etc with option -static.
> >
> > Also I can create a new shared object libQtMaster.so which is composed
> > of all of above static objects (libQtXXX.a),
> 
> This would be all wrong.
> 
> The only reason for compiling several modules into one would be (of the top
> of my head) to
>      1) Get cross-module optimizations (which indicate also cross-compile-unit
> optimizations, so you'll need a bin tools chain which can do that) to a) reduce
> code size, and b) improve performance.
>      2) Reduce number of exported symbols.
>      3) Faster shared library load time.
> 
> To do this you would have to compile each of the modules as normal (shared
> library), and then have a step which links all of the object files into one
> shared library, maybe called just qt5.so
> 
> Configuring as static only to gather them into a shared lib is wrong.
> 
> 
> > then I want my Qt application be dynamic linked with this libQtMain.so by:
> >
> > QT += master
> >
> > so how to create this new QT module "master" that can be used from the
> > .pro files ?
> 
> This is also wrong, since this would require everyone to change the way they
> create Qt projects. In this case you would want
>      QT += core gui network
> to do the same thing, simply to add linking to this new qt5.so library.
> 
> That way you can keep projects working both with and without this magical
> single library without further adjustments.
> 
> 
> --
> .marius



More information about the Development mailing list