[Qt-interest] static linking

Linda Maria linda.maria.bjork at gmail.com
Fri May 29 16:30:15 CEST 2009


>
> Message: 3
> Date: Thu, 28 May 2009 08:15:30 -0400
> From: John McClurkin <jwm at nei.nih.gov>
> Subject: Re: [Qt-interest] static linking
> To: qt-interest at trolltech.com
> Message-ID: <gvlv94$5n5$1 at eple.troll.no>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> 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.
>
>
Hi and thanks for all the help.

I finally found out what was wrong (other than my hear collor:). When
creating lib with Qt Creator it adds the macro HELLO_WORLD_LIBSHARED_EXPORT to
generated classes. As the name indicates it is not to be used with static
libraries. My lesson is when changing dynamic QT library to static modify
the .pro file and check all autogenerated macros and their purpose.

Thanks all,
Linda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090529/82ff7d8e/attachment.html 


More information about the Qt-interest-old mailing list