Building Qt Statically



  • Hi,
    How to build my application statically? The following link says to run
    cd C:\path\to\Qt
    configure -static <any other options you need>

    After running the configure in the directory QtSDK\QtSource\4.8.1, I tried to rum mingw32-make sub-src but returns in an error as follows
    mingw32-make: *** No rule to make target `sub-src'. Stop



  • Why did you try to build the sub-src target and not just the default target?
    If you include "the following link" it might be easier for someone to help you.



  • I normally make a static Qt build like this:

    If the Qt sources are installed in (say) C:\Qt\qt-4.8.1 I create a parallel directory for the static build:

    C:\Qt\qt-4.8.1-static

    cd into C:\Qt\qt-4.8.1-static and type:

    ..\qt-4.8.1\configure -static <any other options>

    then make to compile.

    For Windows I usually use the library in situ so I would just add the new static build to Qt Creator and build my application with it.

    If the static build is just for deployment I don't bother to build the tools, demos, examples or qt3 support by adding:

    -nomake tools -nomake examples -nomake demos -no-qt3support

    I also skip webkit (saving a significant amount of time in the build) :

    -no-webkit

    In fact, I don't think static builds of WebKit are actually supported: http://qt-project.org/forums/viewthread/5970

    Hope this helps

    Edit:

    Note also this approach requires perl and the build tools (mingw) to be on the path. Be careful with Strawberry Perl - this has its own version of mingw which can conflict with your Qt toolchain. Try ActivePerl or make sure Strawberry Perls C tools are not in the path.



  • Please see the link, sorry it was missed in the previous post
    http://doc-snapshot.qt-project.org/4.8/deployment-windows.html



  • OK. I'm not sure what the sub-src target is supposed to do, but have you tried building without specifying an explicit target? I.e. just make (or mingw32-make)?

    And have you tried doing it the same way you do it on other platforms, using a shadow build?

    I'm not even sure you can build Qt from the distribution that comes with the Qt SDK. That is a precompiled binary release, and it might not be possible to use that to rebuild Qt. I would download the sources separately and build from them instead.



  • [quote author="ras123" date="1341315476"]Hi,
    How to build my application statically? The following link says to run
    cd C:\path\to\Qt
    configure -static <any other options you need>

    After running the configure in the directory QtSDK\QtSource\4.8.1, I tried to rum mingw32-make sub-src but returns in an error as follows
    mingw32-make: *** No rule to make target `sub-src'. Stop
    [/quote]

    you need to run qmake after configure.... its placed in <path-to-qt>\bin after you've run configure...
    @c:\path\to\qt> bin\qmake project.pro //...project.pro is in <path-to-qt>@



  • [quote author="Swatwork" date="1341318369"]
    Note also this approach requires perl and the build tools (mingw) to be on the path. Be careful with Strawberry Perl - this has its own version of mingw which can conflict with your Qt toolchain. Try ActivePerl or make sure Strawberry Perls C tools are not in the path.[/quote]

    Thank you Swatwork, it is just because of perl not installed, now building. Is it possible to use both Static and dynamic linking simultaneously? If yes how? I need static builds for deploying final applications?.



  • I'm not sure what you mean by simultaneously. It's perfectly possible to have different build targets for shared and static libraries, for example a shared debug build and a static release build.

    If you are using Qt Creator and have added the static build to the list of available Qt versions then you can configure the build targets from the project management page. Just specify the static Qt library for the release build.



  • Hi,
    Yes. I need exactly as you said, "a shared debug build and a static release build".

    When I used the qmake which builds statically, to build my application, got the following error
    :-1: error: [ui_xxxx.h] Error 2

    And the compiler output is

    The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project xxxx (target: Desktop)
    When executing build step 'Make'

    But it has no problem with the qmake in Qt Createor

    Thanking You,
    Ras



  • Hi,
    It seems that the problem may with the PATH variable or with the mingw installed with the QtSDK. I added the following path

    C:\QtSDK\QtSources\static\bin;C:\QtSDK\mingw\bin

    And when running minggw32-make, it first tries to run the uic.exe from the path C:\QtSDK\QtSources\4.8.1\bin, but these are actually reside in the directory C:\QtSDK\QtSources\static\bin , why this problem? may be we make qt from a different director?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.