From 478618b4599c98d75c5b7af3f9bd38f1a958b548 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 1 Aug 2023 00:26:47 +0200 Subject: [PATCH] Add a Win32 build. This is in the form of some documentation and a Meson cross file. I don't actually know if the video works, since I don't have working good-enough OpenGL on my Windows VM and it doesn't work properly in WINE. --- cross-prepare.txt | 64 +++++++++++++++++++++++++++++++++++++++++++++++ cross-win32.txt | 26 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 cross-prepare.txt create mode 100644 cross-win32.txt diff --git a/cross-prepare.txt b/cross-prepare.txt new file mode 100644 index 0000000..e986b7c --- /dev/null +++ b/cross-prepare.txt @@ -0,0 +1,64 @@ +# This can probably be executed as a script instead of being run by hand, +# but odds are something is going wrong, so I wouldn't recommend it. :-) +# If this doesn't work for you, feel free to send corrections, but any +# issues here do not count as a bug. + +# Create the directory +sudo mkdir /opt/qt-cross +sudo chown $USER /opt/qt-cross +chmod 0755 /opt/qt-cross + +# Get MinGW +sudo apt install wine64 g++-mingw-w64 +sudo update-alternatives --config x86_64-w64-mingw32-gcc # choose posix +sudo update-alternatives --config x86_64-w64-mingw32-g++ # choose posix + +# Build sqlite3 +wget https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz +tar axvf sqlite-autoconf-3420000.tar.gz +cd sqlite-autoconf-3420000 +./configure --host x86_64-w64-mingw32 --prefix /opt/qt-cross +make -j32 +make install +cd .. + +# Set up CMake cross-compiler file +cat <<'EOF' >/tmp/profile.cmake +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) +EOF + +# Build Qt (completely crazy) +sudo apt-get build-dep qt6-base +sudo apt install qt6-base-dev-tools +apt-get source qt6-base +cd qt6-base-6.4.2+dfsg +wget https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-1.1.1u.zip +unzip openssl-1.1.1u.zip +mkdir src/3rdparty/sqlite/ +cp ../sqlite-autoconf-3420000/sqlite3.[ch] src/3rdparty/sqlite/ +./configure -prefix /opt/qt-cross -no-feature-sql-odbc -platform linux-g++-64 -qt-host-path /usr -xplatform win32-g++ -device-option CROSS_COMPILE=x86_64-w64-mingw32- -release -opengl desktop -nomake examples -no-icu -- -DQT_FORCE_BUILD_TOOLS=ON -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DQt6HostInfo_DIR=/usr/lib/x86_64-linux-gnu/cmake/Qt6HostInfo -DOPENSSL_ROOT_DIR=`pwd`/openssl-1.1 -DFEATURE_vulkan=OFF -DFEATURE_tabletevent=OFF +ninja +ninja install +cd .. + +# Various hacks to get Qt build tools to run properly under Meson +ln -s /usr/lib/qt6/libexec/uic /opt/qt-cross/bin/uic +cp /usr/lib/gcc/x86_64-w64-mingw32/12-posix/{libstdc++-6,libgcc_s_seh-1}.dll /opt/qt-cross/bin +cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /opt/qt-cross/bin + +# Build FFmpeg +git clone https://git.ffmpeg.org/ffmpeg.git +cd ffmpeg +./configure --prefix=/opt/qt-cross --disable-crystalhd --enable-cross-compile --disable-vaapi --disable-vdpau --target-os=mingw64 --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 +make -j32 +make install +cd .. diff --git a/cross-win32.txt b/cross-win32.txt new file mode 100644 index 0000000..e5fa194 --- /dev/null +++ b/cross-win32.txt @@ -0,0 +1,26 @@ +# See cross-prepare.txt for how to set up the environment if you don't +# already have one. (It's not straightforward :-/ ) +# +# Then: meson setup --cross-file cross-win32.txt build-win32 && ninja -C build-win32 +# Note that you'll need to copy and distribute the Qt DLLs together with the .exe file +# if you want it to actually run. +[binaries] +c = 'x86_64-w64-mingw32-gcc' +cpp = 'x86_64-w64-mingw32-g++' +ar = 'x86_64-w64-mingw32-ar' +strip = 'x86_64-w64-mingw32-strip' +pkg-config = 'pkg-config' +exe_wrapper = 'wine' +qmake6 = ['wine', '/opt/qt-cross/bin/qmake6.exe'] +moc = ['wine', '/opt/qt-cross/bin/moc.exe'] +uic = ['wine', '/opt/qt-cross/bin/uic.exe'] +rcc = ['wine', '/opt/qt-cross/bin/rcc.exe'] + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' + +[properties] +pkg_config_libdir = '/opt/qt-cross/lib/pkgconfig' -- 2.39.2