[Qt-interest] static linking
John McClurkin
jwm at nei.nih.gov
Thu May 28 14:15:30 CEST 2009
Oliver Demetz wrote:
> Hmmm, ok
>
> but "trying" takes 3 or 4 hours ;-)
> And I do not want to risk to not be
> able to build my app afterwards.
>
> Is there anybody that just knows whether
> its possible to maintain both versions
> of the qt libs side by side?
>
> Thanks in advance,
> Oliver
>
My understanding is that the OP wants to create her own static library
and link it with her application. This is separate from using static QT
libraries. I routinely use static private libraries with dynamic QT
libraries on both Linux and on WinXP using mingw. (I have troubles in
using Qt with Visual Studio 2005).
In the qmake file for the private static libraries I add the statements:
TEMPLATE = lib
CONFIG += static
When I compile the private libraries I get output files like libRex.a
and libStics.a. There are no output files like libRex.so or libRex.dll
in the library trees. If you do have .so or .dll files, then I think
that the .pro file is wrong and you could check this by looking in the
Makefiles generated by qmake -makefile.
To use these static libraries in an application that links with dynamic
QT libraries I put the statements
INCLUDEPATH += pathToSticsLib pathToRexLib ##to get library headers
LIBS += -LpathToSticsLibRelease -lStics -LpathtoRexLibRelease -lRex
I get applications with dynamically linked QT libraries and statically
linked private libraries. Note, I don't put a static flag in the
application qmake file.
As to having both static and dynamic QT libraries together, my
interpretation of the configure script is that you cannot. To get this I
put a distribution into two different directories, i.e Qt-4.5.0-static
and Qt-4.5.0-dyn, and build each, adding the -static flag to configure
in the static distribution. To save time, I don't build the examples,
demos, tutorials, etc. in the static distribution. This is no different
than having two different versions of Qt. To build against dynamic Qt
libraries, I run qmake from the dynamic distribution. To build against
the static Qt libraries, I run qmake from the static distribution.
More information about the Qt-interest-old
mailing list