Skip to content

Cross compile Mingw 64 for Windows on Linux

Lennart Lopin edited this page Jul 31, 2021 · 12 revisions

Built on Ubuntu 20 for Windows

Install mingw-64

sudo apt-get install mingw-w64

Should give you some output

x86_64-w64-mingw32-g++

First work on the prerequisites

Cross compile BerkelyDB

You need to download and compile Berkely with

sudo ../dist/configure --host=x86_64-w64-mingw32 --enable-mingw --enable-cxx --disable-shared --disable-replication

Cross compile Boost 1.70+

You need to download and compile Boost static with mingw turned on https://www.boost.org/users/history/version_1_70_0.html Download, extract, then:

sudo ./bootstrap.sh

sudo vi user-config.jam

cat using gcc : mingw64 : x86_64-w64-mingw32-g++ ;

sudo ./b2 --with-chrono --with-atomic --with-filesystem --with-iostreams --with-timer --with-system --with-program_options --with-thread address-model=64 target-os=windows toolset=gcc-mingw64 variant=release link=static --user-config=./user-config.jam

./b2 headers

export BOOST_ROOT=/your/path/to/boost

Cross compile Qt5 installation

Download Qt5 > v.5.11 ... we use Qt 5.15.2 https://download.qt.io/archive/qt/5.15/5.15.2/single https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz

For Qt you have to switch to posix version of mingw

$ sudo update-alternatives --config x86_64-w64-mingw32-gcc <choose x86_64-w64-mingw32-gcc-posix from the list>

$ sudo update-alternatives --config x86_64-w64-mingw32-g++ <choose x86_64-w64-mingw32-g++-posix from the list>

You need to download Qt5 Sources and compile static with mingw64 cross compile turned on:

./configure -static -release -xplatform win32-g++ -device-option CROSS_COMPILE=/usr/bin/x86_64-w64-mingw32- -prefix /home/novalis78/Qt5.15.2/mingw_64 -opensource -confirm-license -qt-zlib -qt-libpng -qt-webp -qt-libjpeg -qt-freetype -no-opengl -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qtgamepad -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtsensors -skip qtspeech -skip qtsvg -skip qtwayland -skip qtwebglplugin -skip qtwebview -skip webengine -make libs -nomake tools -nomake examples -nomake tests

make

make install

OpenSSL static cross compile

cd /c/deps/

https://www.openssl.org/source/openssl-1.1.1k.tar.gz

tar xvfz openssl-1.1.1k.tar.gz

cd openssl-1.1.1k

sudo perl Configure no-zlib no-shared no-dso no-camellia no-capieng no-cast no-cms no-dtls1 no-gost no-heartbeats no-idea no-md2 no-mdc2 no-rc5 no-rdrand no-rfc3779 no-sctp no-seed no-whirlpool no-rc2 no-rc4 no-ssl2 no-ssl3 mingw64 -static --static --cross-compile-prefix=x86_64-w64-mingw32-

make

Marscoin cross compile

Configure will be broken - won't find static and cross compiled dependencies. Run it to see if anything else fails. Then edit the Makefile Set manual paths to:

./configure --host=x86_64-w64-mingw32 --with-gui --enable-static QT_LIBS="L/home/path/to/Qt5.15.2/mingw_64/plugins/platforms" --disable-shared BDB_LIBS="-L/opt/db/db4/lib -ldb_cxx-4.8" BDB_CFLAGS="-I/opt/db/db4/include" --with-qt-incdir=/path/to/Qt5.15.2/mingw_64/include --with-qt-libdir=/path/to/Qt5.15.2/mingw_64/lib --disable-tests --with-qt-plugindir=/path/to/Qt5.15.2/mingw_64/plugins --with-qt-bindir=/path/to/Qt5.15.2/mingw_64/bin QT_LIBS="L/path/to/Qt5.15.2/mingw_64/lib" --disable-upnp-default --disable-tests CPPFLAGS="-I/opt/openssl-1.1.1k/include -I/opt/protobuf-2.6.1/src" LDFLAGS="-L/opt/openssl-1.1.1k -L/opt/protobuf-2.6.1/src/.libs"

make

Troubleshooting useful links: