RedPanda-CPP/docs/detailed-build-win.md

7.9 KiB

More Build Instructions for Windows

Library + Toolchain \ Target x86 x64 ARM64
MSYS2 + GNU-based MinGW ✔️ ✔️
MSYS2 + LLVM-based MinGW ✔️ ✔️ ✔️
Windows XP + MinGW UCRT ✔️ ✔️
Qt.io + MinGW ✔️ ✔️
Qt.io + MSVC ✔️ ✔️
vcpkg + MSVC ✔️ ✔️

qmake variables:

  • PREFIX: where $MAKE install installs files to.
  • WINDOWS_PREFER_OPENCONSOLE=ON (make phase): prefer UTF-8 compatible OpenConsole.exe.
    • OpenConsole.exe is a part of Windows Terminal. UTF-8 input support was added in version 1.18.
    • OpenConsole.exe requires ConPTY, which was introduced in Windows 10 1809.

Notes for Windows on ARM:

  • Red Panda C++ can be built for ARM64 ABI only on Windows 11 ARM64, while it is supposed (but not tested) to run on Windows 10 ARM64.
    • ARM64EC (“emulation compatible”) host is not supported, i.e., Red Panda C++ cannot be built with ARM64EC toolchain.
    • ARM64EC target is (theoretically) supported, i.e. Red Panda C++ will build ARM64EC binaries if upstream toolchain supports ARM64EC.
  • With the ARM32 deprecation in Windows 11 Insider Preview Build 25905, ARM32 support will never be added.

Maunally Build in MSYS2

Prerequisites:

  1. Windows 8.1 x64 or later, or Windows 11 ARM64.
  2. Install MSYS2.
  3. In selected environment, install toolchain and Qt 5 library:
    pacman -S \
      $MINGW_PACKAGE_PREFIX-{toolchain,qt5-static} \
      git
    

To build:

  1. In selected environment, set related variables:
    SRC_DIR="/c/src/redpanda-src" # “C:\src\redpanda-src” for example
    BUILD_DIR="/c/src/redpanda-build" # “C:\src\redpanda-build” for example
    INSTALL_DIR="/c/src/redpanda-pkg" # “C:\src\redpanda-pkg” for example
    
  2. Navigate to build directory:
    rm -rf "$BUILD_DIR" # optional for clean build
    mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
    
  3. Configure, build and install:
    $MSYSTEM_PREFIX/qt5-static/bin/qmake PREFIX="$INSTALL_DIR" "$SRC_DIR/Red_Panda_CPP.pro"
    mingw32-make -j$(nproc)
    mingw32-make install
    

Qt.io Qt Library with MinGW Toolchain or MSVC Toolchain

Prerequisites:

  1. Windows 7 x64 or later. ARM64 is not supported.
  2. Install Qt with online installer from Qt.io.
    • Select the library (in Qt group, Qt 5.15.2 subgroup, check at lease one of MinGW 8.1.0 32-bit, MinGW 8.1.0 64-bit, MSVC 2019 32-bit or MSVC 2019 64-bit).
    • For MinGW toolchain, select the toolchain (in Qt group, Developer and Designer Tools subgroup, check MinGW 8.1.0 32-bit or MinGW 8.1.0 64-bit, matching the library).
    • Optionally select Qt Creator (in Qt group, Developer and Designer Tools subgroup; recomended for MSVC toolchain for parallel build support).
  3. For MSVC toolchain, install Visual Studio 2019 or later, or Visual Studio Build Tools 2019 or later, with Desktop Development with C++ workload.
    • In Installation Details panel, under the Desktop Development with C++ workload, select at least one MSVC x86/x64 build tools and one Windows SDK.

To build:

  1. Launch Qt environment from Start Menu.
  2. In Qt environment, set related variables:
    rem no quotes even if path contains spaces
    set SRC_DIR=C:\src\redpanda-src
    set BUILD_DIR=C:\src\redpanda-build
    set INSTALL_DIR=C:\src\redpanda-pkg
    rem for MSVC toolchain
    set VS_INSTALL_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community
    rem for MSVC toolchain; or x86
    set VC_ARCH=amd64
    rem for MSVC toolchain; keep unset if Qt Creator is not installed
    set QT_CREATOR_DIR=C:\Qt\Tools\QtCreator
    
  3. Navigate to build directory:
    rem optional for clean build
    rmdir /s /q "%BUILD_DIR%"
    mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%"
    
  4. Configure, build and install. For MinGW toolchain:
    qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro"
    mingw32-make -j%NUMBER_OF_PROCESSORS%
    mingw32-make install
    windeployqt "%INSTALL_DIR%\RedPandaIDE.exe"
    
    For MSVC toolchain:
    call "%VS_INSTALL_PATH%\Common7\Tools\VsDevCmd.bat" -arch=%VC_ARCH%
    qmake PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro"
    
    set JOM=%QT_CREATOR_DIR%\bin\jom\jom.exe
    if "%QT_CREATOR_DIR%" neq "" (
       "%JOM%" -j%NUMBER_OF_PROCESSORS%
       "%JOM%" install
    ) else (
       nmake
       nmake install
    )
    windeployqt "%INSTALL_DIR%\RedPandaIDE.exe"
    

Advanced Option: vcpkg Qt Static Library with MSVC Toolchain

Prerequisites:

  1. Windows 7 x64 or later. ARM64 is not supported.
    • For a fresh installation of Windows 7, install following components in order:
      1. SHA-2 code signing support (prerequisite of .NET Framework 4.8),
      2. .NET Framework 4.8 (prerequisite of Windows Management Framework 5.1 and Visual Studio; also optional dependency of Git for Windows),
      3. Windows Management Framework 5.1 (prerequisite of vcpkg bootstrapping).
  2. Install Visual Studio 2017 or later, or Visual Studio Build Tools 2017 or later, with Desktop Development with C++ workload.
    • In Installation Details panel, under the Desktop Development with C++ workload, select at least one MSVC x86/x64 build tools and one Windows SDK.
  3. Install standalone vcpkg.
    • As of 2023.08.09, a patch is required for Windows 7 to use compatible version of Python. Affected files will change over time, so manually edit them to apply the patch.
  4. Install Qt with vcpkg.
    $TARGET = "x64-windows-static" # or "x86-windows-static"
    vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET
    

To build with VS 2019 or later in PowerShell (Core) or Windows PowerShell:

  1. Set related variables:
    $SRC_DIR = "C:\src\redpanda-src"
    $BUILD_DIR = "C:\src\redpanda-build"
    $INSTALL_DIR = "C:\src\redpanda-pkg"
    $VCPKG_ROOT = "C:\src\vcpkg"
    $VCPKG_TARGET = "x64-windows-static" # or "x86-windows-static"
    $VS_INSTALL_PATH = "C:\Program Files\Microsoft Visual Studio\2022\Community"
    $VC_ARCH = "amd64" # or "x86"
    $JOM = "$VCPKG_ROOT\downloads\tools\jom\jom-1.1.3\jom.exe" # check the version
    
  2. Navigate to build directory:
    Remove-Item -Recurse -Force "$BUILD_DIR" # optional for clean build
    (New-Item -ItemType Directory -Force "$BUILD_DIR") -and (Set-Location "$BUILD_DIR")
    
  3. Configure, build and install:
    Import-Module "$VS_INSTALL_PATH\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
    Enter-VsDevShell -VsInstallPath "$VS_INSTALL_PATH" -SkipAutomaticLocation -DevCmdArguments "-arch=$VC_ARCH"
    & "$VCPKG_ROOT\installed\$VCPKG_TARGET\tools\qt5\bin\qmake.exe" PREFIX="$INSTALL_DIR" "$SRC_DIR\Red_Panda_CPP.pro"
    & "$JOM" "-j${Env:NUMBER_OF_PROCESSORS}"
    & "$JOM" install
    

To build with VS 2017 or later in Command Prompt:

  1. Launch proper VC environment from Start Menu.
  2. Set related variables:
    rem no quotes even if path contains spaces
    set SRC_DIR=C:\src\redpanda-src
    set BUILD_DIR=C:\src\redpanda-build
    set INSTALL_DIR=C:\src\redpanda-pkg
    set VCPKG_ROOT=C:\src\vcpkg
    rem or x86-windows-static
    set VCPKG_TARGET=x64-windows-static
    rem check the version
    set JOM=%VCPKG_ROOT%\downloads\tools\jom\jom-1.1.3\jom.exe
    
  3. Navigate to build directory:
    rem optional for clean build
    rmdir /s /q "%BUILD_DIR%"
    mkdir "%BUILD_DIR%" && cd /d "%BUILD_DIR%"
    
  4. Configure, build and install:
    "%VCPKG_ROOT%\installed\%VCPKG_TARGET%\tools\qt5\bin\qmake.exe" PREFIX="%INSTALL_DIR%" "%SRC_DIR%\Red_Panda_CPP.pro"
    "%JOM%" -j%NUMBER_OF_PROCESSORS%
    "%JOM%" install