Compiling Qt statically on Windows XP and MinGW fail. Is it possible to achieve?
Question: I need to compile Qt statically. I have to do it on a virtual machine running
Windows XP. Because of this requirement, I can't use the PowerShell 3.0 script
suggested in the wiki page [How to build a static Qt for
Windows/MinGW](http://qt-project.org/wiki/How-to-build-a-static-Qt-for-
Windows-MinGW) (PowerShell 3.0 can't be installed on WinXP).

I tried to read the script and do its work step by step manually.

I added to the end of `C:\Qt\5.3\Src\qtbase\mkspecs\win32-g++\qmake.conf`
file:

    
    
    # [QT-STATIC-PATCH]
    QMAKE_LFLAGS += -static -static-libgcc
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer
    DEFINES += QT_STATIC_BUILD
    

I ran the configuration:

    
    
    mkdir C:\Qt\5.3\Static-build
    cd C:\Qt\5.3\Static-build
    ..\Src\configure.bat -static -debug-and-release -platform win32-g++ \
    -prefix C:\Qt\5.3\Static -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg \
    -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl -opensource \
    -confirm-license -make libs -nomake tools -nomake examples -nomake tests
    

and that seems OK:

    
    
    This is the Qt for Windows Open Source Edition.
    
    You have already accepted the terms of the license.
    
    Creating qmake...
    mingw32-make: Nothing to be done for 'first'.
    Running configuration tests...
    Environment:
        INCLUDE=
          Unset
        LIB=
          Unset
        PATH=
          C:\Qt\5.3\mingw482_32\bin
          C:\Qt\Tools\mingw482_32\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\Program Files\Git\git-cheetah\..\bin
          C:\WINDOWS\system32
          C:\WINDOWS
          C:\WINDOWS\System32\Wbem
          C:\Program Files\Git\cmd
          C:\Program Files\TortoiseGit\bin
          C:\Program Files\CMake\bin
          C:\Python27
          C:\StrawberryPerl\perl\bin
          C:\StrawberryPerl\win32
          C:\WINDOWS\system32\WindowsPowerShell\v1.0
    Configuration:
        pcre
        debug
        compile_examples
    Qt Configuration:
        minimal-config
        small-config
        medium-config
        large-config
        full-config
        debug_and_release build_all release
        debug
        c++11
        static
        zlib
        gif
        jpeg
        png
        freetype
        build_all
        accessibility
        opengl
        audio-backend
        native-gestures
        qpa
        iconv
        concurrent
    
    QMAKESPEC...................win32-g++ (commandline)
    Architecture................i386, features:
    Host Architecture...........i386, features:
    Maketool....................mingw32-make
    Debug build.................yes (combined)
    Default build...............debug
    Force debug info............no
    C++11 support...............yes
    Link Time Code Generation...no
    Accessibility support.......yes
    RTTI support................yes
    SSE2 support................yes
    SSE3 support................yes
    SSSE3 support...............yes
    SSE4.1 support..............yes
    SSE4.2 support..............yes
    AVX support.................yes
    AVX2 support................yes
    NEON support................no
    IWMMXT support..............no
    OpenGL support..............yes
    Large File support..........yes
    NIS support.................no
    Iconv support...............yes
    Evdev support...............no
    Mtdev support...............no
    Inotify support.............no
    eventfd(7) support..........no
    Glib support................no
    CUPS support................no
    OpenVG support..............no
    OpenSSL support.............no
    Qt D-Bus support............no
    Qt Widgets module support...yes
    Qt GUI module support.......yes
    QML debugging...............yes
    DirectWrite support.........no
    Use system proxies..........no
    
    QPA Backends:
        GDI.....................yes
        Direct2D................no
    
    Third Party Libraries:
        ZLIB support............qt
        GIF support.............yes
        JPEG support............yes
        PNG support.............yes
        FreeType support........yes
        Fontconfig support......no
        HarfBuzz-NG support.....no
        PCRE support............qt
        ICU support.............no
        ANGLE...................no
        Dynamic OpenGL..........no
    
    Styles:
        Windows.................yes
        Windows XP..............yes
        Windows Vista...........yes
        Fusion..................yes
        Windows CE..............no
        Windows Mobile..........no
    
    Sql Drivers:
        ODBC....................no
        MySQL...................no
        OCI.....................no
        PostgreSQL..............no
        TDS.....................no
        DB2.....................no
        SQLite..................yes (qt)
        SQLite2.................no
        InterBase...............no
    
    Sources are in..............C:\Qt\5.3\Src\qtbase
    Build is done in............C:\Qt\5.3\Static-build\qtbase
    Install prefix..............C:\Qt\5.3\Static
    Headers installed to........C:\Qt\5.3\Static\include
    Libraries installed to......C:\Qt\5.3\Static\lib
    Arch-dep. data to...........C:\Qt\5.3\Static
    Plugins installed to........C:\Qt\5.3\Static\plugins
    Library execs installed to..C:\Qt\5.3\Static\bin
    QML1 imports installed to...C:\Qt\5.3\Static\imports
    QML2 imports installed to...C:\Qt\5.3\Static\qml
    Binaries installed to.......C:\Qt\5.3\Static\bin
    Arch-indep. data to.........C:\Qt\5.3\Static
    Docs installed to...........C:\Qt\5.3\Static\doc
    Translations installed to...C:\Qt\5.3\Static\translations
    Examples installed to.......C:\Qt\5.3\Static\examples
    Tests installed to..........C:\Qt\5.3\Static\tests
    WARNING: Using static linking will disable the use of plugins.
             Make sure you compile ALL needed modules into the library.
    
    Generating Makefiles...
    
    
    Qt is now configured for building. Just run mingw32-make.
    To reconfigure, run mingw32-make confclean and configure.
    

But the compilation with mingw32-make failed at some point:

    
    
    cd qml/ && ( test -e Makefile || c:/Qt/5.3/Static-build/qtbase/bin/qmake.exe C:/Qt/5.3/Src/qtdeclarative/tools/qml/qml.pro -o
     Makefile ) && c:/Qt/Tools/mingw482_32/bin/mingw32-make -f Makefile
    'QT_PLUGIN_PATH' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    Project ERROR: Failed to parse qmlimportscanner output.
    Makefile:94: recipe for target 'sub-qml-make_first' failed
    mingw32-make[2]: *** [sub-qml-make_first] Error 3
    mingw32-make[2]: Leaving directory 'c:/Qt/5.3/Static-build/qtdeclarative/tools'
    Makefile:66: recipe for target 'sub-tools-make_first' failed
    mingw32-make[1]: *** [sub-tools-make_first] Error 2
    mingw32-make[1]: Leaving directory 'c:/Qt/5.3/Static-build/qtdeclarative'
    Makefile:101: recipe for target 'module-qtdeclarative-make_first' failed
    mingw32-make: *** [module-qtdeclarative-make_first] Error 2
    

Sorry for the french wording. The interesting point is:

> 'QT_PLUGIN_PATH' is not recognized as internal or external command, an
> executable program or a command file

I found other people having the same issue ([here](http://qt-
project.org/forums/viewthread/38552)) and tried the solution they suggested
(from [here](https://github.com/Alexpux/MINGW-
packages/blob/master/mingw-w64-qt5/qt-5.3.0-static-qmake-conf.patch)):

I added

    
    
    QMAKE_LFLAGS_STATIC_LIB += -static
    

to qtbase/mkspecs/win32-g++/qmake.conf and added

    
    
    static:win32: QMAKE_LFLAGS += $$QMAKE_LFLAGS_STATIC_LIB
    

to qtbase/mkspecs/features/default_post.prf

I still have the error.

So I have 2 questions:

  1. **Do you know if it is possible to compile Qt 5.3 on Windows XP with MinGW?**
  2. **Does someone know how to fix the error`'QT_PLUGIN_PATH' is not recognized [...]`?**


Answer: Ok, for a weird reason, after closing my console, re-opening it and re-trying,
it worked :/ I leave this question open in case that someone have a better
explanation for "'QT_PLUGIN_PATH' is not recognized [...]" error. Apparently I
was not the first to get stuck on this error.

