Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cross compiling for win with mingw on linux.
Forum Updated to NodeBB v4.3 + New Features

Cross compiling for win with mingw on linux.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 783 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andeksan
    wrote on 19 Dec 2020, 13:31 last edited by
    #1

    Hi all,

    I am interesting to compile win app(qml) on linux with qt framework 5.4.1. I was able to compile icu, openssl and qt statically, and when i compiled some examples from qt directory: Examples\Qt-5.4\gui, Examples\Qt-5.4\qml most of them do not work, moreover some qt tools do not work too(how it looks like: appear for a moment and close silently or appears only white window). For example: tutorials\extending-qml\chapter1-basics. It shows only white window without content. I have two assumptions about this behavior. 1) for successful run i need to plug some of the dlls/plugins. 2) cross compiled qt was wrongly compiled/configured.
    I am interesting, does somebody encountered similar problem and may be someone was able to fix. Or generally, it is bad idea to compile win app on linux?

    MICRO_ARC=i686
    MINGW_COMPILER=$MICRO_ARC-w64-mingw32

    ICU

    git clone https://github.com/unicode-org/icu.git && cd ./icu && git checkout tags/release-57-1 && \
        mkdir build-lin build-win && \
        cd ~/icu/build-lin && ../icu4c/source/configure && make -j$(nproc) && \
        cd ~/icu/build-win && ../icu4c/source/configure --enable-static --disable-shared --host=$MINGW_COMPILER --with-cross-build=$PWD/../build-lin --prefix=$ICU_INSTALL_DIR && \
        make -j$(nproc) && make install
    

    OPENSSL

    git clone https://github.com/openssl/openssl.git && cd ./openssl && git checkout tags/OpenSSL_1_0_2 && \
        TYPE=$(case $MICRO_ARC in (*i?86*) echo mingw ;; (*x86_64*) echo mingw64 ;; (*) false;; esac) && \
        ./Configure no-asm no-shared $TYPE --cross-compile-prefix=$MINGW_COMPILER- --prefix=$OPENSSL_INSTALL_DIR && make && make install
    

    QT
    Added at the end of files these lines: qt5/qtbase/mkspecs/win32-g++/qmake.conf
    QMAKE_LFLAGS += -static -static-libgcc
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer -ldl
    DEFINES += QT_STATIC_BUILD

    export OPENSSL_LIBS='-lssl -lcrypto -lgdi32' && cd ~/qt5 && \
        ./configure \
            -static \
            -release \
            -xplatform win32-g++ \
            -device-option CROSS_COMPILE=$MINGW_COMPILER- \
            -device-option PKG_CONFIG=$MICRO_ARC-w64-mingw32-pkg-config -force-pkg-config \
            -prefix $QT_INSTALL_DIR \
            -opensource -confirm-license -optimized-qmake \
            -reduce-exports -reduce-relocations \
            -qt-pcre -make libs \
            -make tools -qt-libpng -qt-libjpeg \
            -no-compile-examples -nomake examples -nomake tests \
            -icu -I $ICU_INSTALL_DIR/include -L $ICU_INSTALL_DIR/lib \
            -openssl-linked -I $OPENSSL_INSTALL_DIR/include -L $OPENSSL_INSTALL_DIR/lib \
            -skip qtactiveqt -skip qtdoc 2>&1 | tee config.out && \
        make -j$(nproc) && make install -j$(nproc)
    
    A 1 Reply Last reply 19 Dec 2020, 19:24
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Dec 2020, 18:19 last edited by
      #2

      Hi,

      It would be way simpler to directly built your application on Linux.

      Cross-compilation from Windows to Linux is really much more trouble than using a virtual machine with Linux installed.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Andeksan
        19 Dec 2020, 13:31

        Hi all,

        I am interesting to compile win app(qml) on linux with qt framework 5.4.1. I was able to compile icu, openssl and qt statically, and when i compiled some examples from qt directory: Examples\Qt-5.4\gui, Examples\Qt-5.4\qml most of them do not work, moreover some qt tools do not work too(how it looks like: appear for a moment and close silently or appears only white window). For example: tutorials\extending-qml\chapter1-basics. It shows only white window without content. I have two assumptions about this behavior. 1) for successful run i need to plug some of the dlls/plugins. 2) cross compiled qt was wrongly compiled/configured.
        I am interesting, does somebody encountered similar problem and may be someone was able to fix. Or generally, it is bad idea to compile win app on linux?

        MICRO_ARC=i686
        MINGW_COMPILER=$MICRO_ARC-w64-mingw32

        ICU

        git clone https://github.com/unicode-org/icu.git && cd ./icu && git checkout tags/release-57-1 && \
            mkdir build-lin build-win && \
            cd ~/icu/build-lin && ../icu4c/source/configure && make -j$(nproc) && \
            cd ~/icu/build-win && ../icu4c/source/configure --enable-static --disable-shared --host=$MINGW_COMPILER --with-cross-build=$PWD/../build-lin --prefix=$ICU_INSTALL_DIR && \
            make -j$(nproc) && make install
        

        OPENSSL

        git clone https://github.com/openssl/openssl.git && cd ./openssl && git checkout tags/OpenSSL_1_0_2 && \
            TYPE=$(case $MICRO_ARC in (*i?86*) echo mingw ;; (*x86_64*) echo mingw64 ;; (*) false;; esac) && \
            ./Configure no-asm no-shared $TYPE --cross-compile-prefix=$MINGW_COMPILER- --prefix=$OPENSSL_INSTALL_DIR && make && make install
        

        QT
        Added at the end of files these lines: qt5/qtbase/mkspecs/win32-g++/qmake.conf
        QMAKE_LFLAGS += -static -static-libgcc
        QMAKE_CFLAGS_RELEASE -= -O2
        QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer -ldl
        DEFINES += QT_STATIC_BUILD

        export OPENSSL_LIBS='-lssl -lcrypto -lgdi32' && cd ~/qt5 && \
            ./configure \
                -static \
                -release \
                -xplatform win32-g++ \
                -device-option CROSS_COMPILE=$MINGW_COMPILER- \
                -device-option PKG_CONFIG=$MICRO_ARC-w64-mingw32-pkg-config -force-pkg-config \
                -prefix $QT_INSTALL_DIR \
                -opensource -confirm-license -optimized-qmake \
                -reduce-exports -reduce-relocations \
                -qt-pcre -make libs \
                -make tools -qt-libpng -qt-libjpeg \
                -no-compile-examples -nomake examples -nomake tests \
                -icu -I $ICU_INSTALL_DIR/include -L $ICU_INSTALL_DIR/lib \
                -openssl-linked -I $OPENSSL_INSTALL_DIR/include -L $OPENSSL_INSTALL_DIR/lib \
                -skip qtactiveqt -skip qtdoc 2>&1 | tee config.out && \
            make -j$(nproc) && make install -j$(nproc)
        
        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 19 Dec 2020, 19:24 last edited by
        #3

        Hi @Andeksan,

        you can checkout the MXE cross environment for cross-compiling from Linux to Windows. It automates most of the boring stuff.

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Andeksan
          wrote on 21 Dec 2020, 09:49 last edited by Andeksan
          #4

          Thanks for replies, now i understand that, generally this approach does not worth to spend time. Probably i will change my focus on wine+installed qt. it should be more reliable variant.

          1 Reply Last reply
          0

          1/4

          19 Dec 2020, 13:31

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved