How to build a static Qt 5.0.2 in windows



  • Hi,
    I'm a beginner of Qt. I have a project of converting the html page to png file by calling API of QtWebKit. It's very simple and I have finished it in Qt Creator. But I need to build my project to a single lib file, as that it is very easy to deploy without Qt. I know that the result lib file will very big, but it does not matter.
    I work with Qt 5.0 in Windows XP SP3 and I have also VS2010.
    I know that I need build a static Qt, it's very difficult and I encounter a problem, my steps are:

    download and unzip

    qt-everywhere-opensource-src-5.0.2 and unzip

    icu4c-51_2-Win32-msvc10

    download and install:

    ActivePerl-5.16.3.1603-MSWin32-x86-296746

    ActivePython-2.7.2.5-win32-x86

    rubyinstaller-2.0.0-p195

    mingw-get-inst-20120426, Win32OpenSSL-1_0_1e

    Win32OpenSSL-1_0_1e

    open cmd.exe

    set environment

    set INCLUDE=D:\icu\include;D:\OpenSSL-Win32\include

    set LIB=D:\icu\lib;D:\OpenSSL-Win32\lib

    set path=%PATH%;D:\icu\bin;D:\MinGW\bin

    and all environment variables are:
    @ALLUSERSPROFILE=C:\Documents and Settings\All Users
    APPDATA=C:\Documents and Settings\Administrator\Application Data
    CLIENTNAME=HARRY-PC
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=TEST8
    ComSpec=C:\WINDOWS\system32\cmd.exe
    DXSDK_DIR=C:\Program Files\Microsoft DirectX SDK (June 2010)
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Documents and Settings\Administrator
    INCLUDE=D:\icu\include;D:\OpenSSL-Win32\include
    J2D_D3D=false
    LIB=D:\icu\lib;D:\OpenSSL-Win32\lib
    LOGONSERVER=\TEST8
    NUMBER_OF_PROCESSORS=1
    OS=Windows_NT
    Path=C:\Program Files\Microsoft DirectX SDK (June 2010)\Utilities\Bin\x86;D:\Ruby200\bin;D:\Python27;D:\Python27\Scripts;D:\Perl\site\bin;D:\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;%APPDATA%\Python\Scripts;D:\icu\bin;D:\MinGW\bin;
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.py;.pyw;.RB;.RBW
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 58 Stepping 9, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=3a09
    ProgramFiles=C:\Program Files
    PROMPT=$P$G
    SESSIONNAME=RDP-Tcp#2
    SystemDrive=C:
    SystemRoot=C:\WINDOWS
    TEMP=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
    TMP=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
    USERDOMAIN=TEST8
    USERNAME=Administrator
    USERPROFILE=C:\Documents and Settings\Administrator
    VS100COMNTOOLS=C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools
    windir=C:\WINDOWS
    @

    run configure -prefix D:\qt-5.0.2\qtbase -confirm-license -opensource -platform win32-g++ -opengl desktop -release -static -openssl -nomake tests -nomake examples

    run mingw32-make and I got some errors:

    @g++ -Wl,-s -Wl,-subsystem,console -o D:\qt-5.0.2\qtbase\bin\xmlpatterns.exe .obj/release_static/main.o .obj/release_static/qapplicationargument.o .obj/release_static/qapplicationargumentparser.o -LD:\icu\lib -LD:\OpenSSL-Win32\lib -LD:/qt-5.0.2/qtbase/lib -lQt5XmlPatterns -lQt5Network -ldnsapi -lcrypt32 -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lsicuin -lsicuuc -lsicudt
    d:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lsicuin
    d:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lsicuuc
    d:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lsicudt
    collect2: ld return 1
    mingw32-make[4]: *** [D:\qt-5.0.2\qtbase\bin\xmlpatterns.exe] Error 1
    mingw32-make[4]: Leaving directory D:/qt-5.0.2/qtxmlpatterns/tools/xmlpatterns' mingw32-make[3]: *** [release] Error 2 mingw32-make[3]: Leaving directoryD:/qt-5.0.2/qtxmlpatterns/tools/xmlpatterns'
    mingw32-make[2]: *** [sub-xmlpatterns-make_first] Error 2
    mingw32-make[2]: Leaving directory D:/qt-5.0.2/qtxmlpatterns/tools' mingw32-make[1]: *** [sub-tools-make_first] Error 2 mingw32-make[1]: Leaving directoryD:/qt-5.0.2/qtxmlpatterns'
    mingw32-make: *** [module-qtxmlpatterns-make_first] Error 2
    @

    I don't know how to fix this problem. Is there some errors in my steps? Please tell me. Or is there any article about building a static Qt 5.0.2 in Windows? I have read many article in this site, but there is no a step-by-step article about build static Qt 5.

    Any replay would be helpful, thank you.



  • AFAIK, ICU was not designed to be built statically and so is QtWebkit.

    You can build Qt5 statically but you will remove webkit support.


  • Moderators

    MinGW and MSVC are not compatible compilers! So the linker is not able to link ICU compiled in MSVC with Qt compiled using MinGW.

    You need to build everything with MinGW, or switch to MSVC. Also, consider using Qt 5.1, it has received many fixes in static building.



  • Thanks for your reply.
    Another question, if I build a static Qt without ICU, will my Qt support internationalization? In Qt 5.0, we need to build webkit individually, is right? Does it mean that ICU is just required when I build webkit?
    [quote author="Code_ReaQtor" date="1369997741"]AFAIK, ICU was not designed to be built statically and so is QtWebkit.

    You can build Qt5 statically but you will remove webkit support.[/quote]



  • Thanks for your reply.
    Yes, I built everything with MinGW.
    [quote author="sierdzio" date="1369997893"]MinGW and MSVC are not compatible compilers! So the linker is not able to link ICU compiled in MSVC with Qt compiled using MinGW.

    You need to build everything with MinGW, or switch to MSVC. Also, consider using Qt 5.1, it has received many fixes in static building.[/quote]


  • Moderators

    No, you have clearly stated: "icu4c-51_2-Win32-msvc10" see that 'msvc10' there?

    ICU is used by WebKit and QtCore. I have not compiled Qt5 statically, so I don't know the behaviour of ICU there.



  • Thank you very much. I got it this time.
    [quote author="sierdzio" date="1370412426"]No, you have clearly stated: "icu4c-51_2-Win32-msvc10" see that 'msvc10' there?

    ICU is used by WebKit and QtCore. I have not compiled Qt5 statically, so I don't know the behaviour of ICU there.[/quote]


Log in to reply
 

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