diff --git a/doc/win/DEVELOPING.md b/doc/win/DEVELOPING.md new file mode 100644 index 0000000..048344a --- /dev/null +++ b/doc/win/DEVELOPING.md @@ -0,0 +1,118 @@ +# Crosscompile for Windows (only tested for Debian Bullseye 11) + +Last updated on October 31, 2021 - happy halloween!!! +We are testing with Qt 5.15.2 and we'll see... + +## build dependencies +``` +sudo apt install -y clang g++ build-essential make mingw-w64 git pkg-config libc6-dev m4 g++-multilib autoconf libncurses-dev libtool-bin unzip python2 python3-zmq zlib1g-dev wget curl bsdmainutils automake libgl1-mesa-dev libglu1-mesa-dev libfontconfig1-dev autopoint libssl-dev + +sudo apt-get install qtbase5-dev qt5-qmake libqt5websockets5-dev qtcreator +``` + +### MXE dependencies + +Below we have the list I tested with, but you can also cross reference the [upstream requirements documentation](https://mxe.cc/#requirements) for the latest list. + +``` +sudo apt install -y bash bison bzip2 flex gettext gperf intltool libc6-dev-i386 libgdk-pixbuf2.0-dev libltdl-dev libtool-bin libxml-parser-perl lzip make openssl p7zip-full patch perl pkg-config python ruby sed unzip xz-utils +``` + +### and yet even more dependencies... +``` +apt-get -y update && \ +apt-get install -y libdbus-1-3 libexpat1 \ + libgl1-mesa-dev libglu1-mesa-dev libfontconfig1-dev libssl-dev \ + libfreetype6 libgl1-mesa-glx libglib2.0-0 libx11-6 libx11-xcb1 \ + cmake clang++-6.0 software-properties-common gperf libtool \ + libgdk-pixbuf2.0-dev libltdl-dev + +# needed for QT 5.15.x +sudo apt install -y libxcb-sync-dev libxcb-xinerama0-dev +``` + +## Compile OpenSSL + +QT 5.15.2 has a [known issue list](https://wiki.qt.io/Qt_5.15.2_Known_Issues) +that currently lists that OpenSSL version 1.1.1 be used + +``` +# Download openssl 1.1.1 from https://openssl.org/source/ + +wget https://www.openssl.org/source/openssl-1.1.1.tar.gz +tar zxvpf openssl-1.1.1.tar.gz +cd openssl-1.1.1 +./config +make -j$(nproc) +``` + +### Integrate libsodium for mingw + +Compilation keeps bailing stating that it doesn't have libsodium, so now to set this up... + +``` +wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-mingw.tar.gz +tar zxvpf libsodium-1.0.18-stable-mingw.tar.gz +``` + +This will be the SODIUM_STATIC path further down. + +## Static build of Qt5 + +### Download Qt5 sources +``` +mkdir -p ~/Qt/5.15.2 +cd ~/Qt/5.15.2 + +wget https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz +tar xvpf qt-everywhere-src-5.15.2.tar.xz +cd qt-everywhere-src-5.15.2 +``` + +### Configure and build Qt5 statically. +``` +# trying to get libsodium not failing... +## OPENSSL_LIBS='-L/PATH/TO/openssl-1.1.1 -lssl -lcrypto' ./configure -static -prefix ~/Qt/5.15.2/static -skip qtlocation -skip qtmacextras -skip qtpurchasing -skip qtscript -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtdatavis3d -skip qtdoc -skip qtcharts -skip qtdeclarative -skip qt3d -skip qtwebengine -skip qtandroidextras -skip qtwebview -skip qtgamepad -skip qtquickcontrols -skip qtquickcontrols2 -skip qtremoteobjects -skip qtwebview -skip qtwebchannel -skip qtwebglplugin -nomake examples -nomake tests -qt-zlib -qt-libpng -feature-fontconfig -no-feature-getentropy -release -openssl-linked -opensource + +OPENSSL_LIBS='-L/PATH/TO/openssl-1.1.1 SODIUM_STATIC=-L/PATH/TO/libsodium-win64/lib -lssl -lcrypto -lsodium' ./configure -static -prefix ~/Qt/5.15.2/static -skip qtlocation -skip qtmacextras -skip qtpurchasing -skip qtscript -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtdatavis3d -skip qtdoc -skip qtcharts -skip qtdeclarative -skip qt3d -skip qtwebengine -skip qtandroidextras -skip qtwebview -skip qtgamepad -skip qtquickcontrols -skip qtquickcontrols2 -skip qtremoteobjects -skip qtwebview -skip qtwebchannel -skip qtwebglplugin -nomake examples -nomake tests -qt-zlib -qt-libpng -feature-fontconfig -no-feature-getentropy -release -openssl-linked -opensource + +gmake -j$(nproc) +gmake -j$(nproc) install +``` + +My own Random Notes I came across while figuring this all out for this newer version of QT... +- had error re: -qt-xcb flag and found [this write](https://forum.qt.io/topic/115827/build-on-linux-qt-xcb-option/18) explaining what to add in there +- had error re: -qt-xkbcommon flag and [found this](https://forum.qt.io/post/677389) re "It seems that -qt-xcb option was removed from 5.12.1 onward?" +- now I get [this error](https://github.com/microsoft/vcpkg/issues/15150) +- possible solution to install certain packages, which configure and (g)make now all work when we identify their names on Debian [libxcb-sync-dev libxcb-xinerama0-dev] + +## Build MXE (Cross-compiled Qt5 for Windows in Linux) +``` +mkdir ~/git +cd ~/git +git clone https://github.com/mxe/mxe.git +cd mxe + +make -j$(nproc) MXE_TARGETS=x86_64-w64-mingw32.static qtbase qtwebsockets +``` + +## Build SilentDragonLite .exe +``` +git clone https://git.hush.is/hush/SilentDragonLite +cd SilentDragonLite + +# I'm using rust 1.56.0 from rustup, so not running this command +# if you have newer rustc, then stick with that +curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.49.0 -y + +# if not already in your .bashrc... +echo 'source $HOME/.cargo/env' >> $HOME/.bashrc + +# add win64 to rust +~/.cargo/bin/rustup target add x86_64-pc-windows-gnu +echo "[target.x86_64-pc-windows-gnu]" >> ~/.cargo/config +echo "linker = 'x86_64-w64-mingw32.static-gcc'" >> ~/.cargo/config + +MXE_PATH="/home/your_username/git/mxe/usr/bin" QT_STATIC="/home/your_username/Qt/5.15.2/static" \ +APP_VERSION="1.5.2" PREV_VERSION="1.5.0" ./src/scripts/win-mkrelease-only.sh +``` diff --git a/src/scripts/win-mkrelease-only.sh b/src/scripts/win-mkrelease-only.sh new file mode 100755 index 0000000..1749993 --- /dev/null +++ b/src/scripts/win-mkrelease-only.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# usage: ./src/scripts/mkrelease.sh from root dir +# with QT_STATIC, MXE_PATH, APP_VERSION, PREV_VERSION variables set +if [ -z $QT_STATIC ]; then + echo "QT_STATIC is not set. Please set it to the base directory of a statically compiled Qt"; + exit 1; +fi + +if [ -z $APP_VERSION ]; then echo "APP_VERSION is not set"; exit 1; fi +if [ -z $PREV_VERSION ]; then echo "PREV_VERSION is not set"; exit 1; fi + +if [ -z $MXE_PATH ]; then + echo "MXE_PATH is not set. Set it to /home/your_username/git/mxe/usr/bin if you want to build Windows with changing your_username" + echo "Not building Windows" + exit 0; +fi + +echo -n "Version files.........." +# Replace the version number in the .pro file so it gets picked up everywhere +sed -i "s/${PREV_VERSION}/${APP_VERSION}/g" silentdragon-lite.pro > /dev/null +# Also update it in the README.md +sed -i "s/${PREV_VERSION}/${APP_VERSION}/g" README.md > /dev/null +echo "[OK]" + +echo -n "Cleaning..............." +rm -rf bin/* +rm -rf artifacts/* +make distclean >/dev/null 2>&1 +echo "[OK]" + +echo "" +echo "[Building on" `lsb_release -r`"]" + +echo -n "Configuring............" +QT_STATIC=$QT_STATIC bash src/scripts/dotranslations.sh >/dev/null +$QT_STATIC/bin/qmake silentdragon-lite.pro -spec linux-clang CONFIG+=release > /dev/null +rm -rf bin/SilentDragonLite* > /dev/null +echo "[OK]" + +echo "" +echo "[Windows]" +mkdir release +export PATH=$MXE_PATH:$PATH + +echo -n "Configuring............" +make clean > /dev/null +rm -f SilentDragonLite-mingw.pro +rm -rf release/ +mkdir release +cp src/precompiled.h release/ +#Mingw seems to have trouble with precompiled headers, so strip that option from the .pro file +cat silentdragon-lite.pro | sed "s/precompile_header/release/g" | sed "s/PRECOMPILED_HEADER.*//g" > SilentDragonLite-mingw.pro +echo "[OK]" + +echo -n "Building..............." +cp src/precompiled.h release/ +# Build the lib first +cd lib && make winrelease && cd .. +cp src/precompiled.h release/ +# figure how to lupdate & lrelease with qt... here... +#x86_64-w64-mingw32.static-qmake-qt5 silentdragon-lite.pro CONFIG+=release > /dev/null +x86_64-w64-mingw32.static-qmake-qt5 SilentDragonLite-mingw.pro CONFIG+=release > /dev/null +cp src/precompiled.h release/ +make -j32 > /dev/null +echo "[OK]" + +echo -n "Packaging.............." +mkdir release/SilentDragonLite-v$APP_VERSION +cp release/SilentDragonLite.exe release/SilentDragonLite-v$APP_VERSION +cp README.md release/SilentDragonLite-v$APP_VERSION +cp LICENSE release/SilentDragonLite-v$APP_VERSION +cd release && zip -r Windows-binaries-SilentDragonLite-v$APP_VERSION.zip SilentDragonLite-v$APP_VERSION/ > /dev/null +cd .. + +mkdir artifacts >/dev/null 2>&1 +cp release/Windows-binaries-SilentDragonLite-v$APP_VERSION.zip ./artifacts/ +echo "[OK]" + +if [ -f artifacts/Windows-binaries-SilentDragonLite-v$APP_VERSION.zip ] ; then + echo -n "Package contents......." + if unzip -l "artifacts/Windows-binaries-SilentDragonLite-v$APP_VERSION.zip" | wc -l | grep -q "9"; then + echo "[OK]" + else + echo "[ERROR]" + exit 1 + fi +else + echo "[ERROR]" + exit 1 +fi