Skip to content

Build cutechess with Qt5 static

ppigazzini edited this page Aug 20, 2020 · 19 revisions

Multi Variant Fishtest needs an updated version of cutechess-cli, a command-line interface and a library for playing chess. To maximize the compatibility with the workers running fishtest, use these instructions to build cutechess-cli.exe static on Windows and cutechess-cli with Qt5 static on Linux. The building process requires some time.

Windows

Download and install MSYS2 using the default settings and follow the official instructions to update the MSYS2 packages (here below the shortest way):

  1. pacman -Syuu to update the core packages
  2. pacman -Syuu to update the other packages

32 bit version (suggested for fishtest, works on Windows 32/64 bit)

  1. start a MSYS2 MinGW 32-bit console
  2. write and start this script:
#!/bin/bash
# http://stackoverflow.com/a/34001073/1583123

# update and install packages
pacman -S --noconfirm git make zip mingw-w64-i686-gcc mingw-w64-i686-jasper mingw-w64-i686-zstd mingw-w64-i686-qt5-static

# build cutechess-cli and cutechess
git clone https://github.com/cutechess/cutechess.git
cd cutechess

# checkout the latest tag
git fetch -p --tags --all
tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $tag -b latest

git log --oneline -n 5 > ../cutechess.git.log
/mingw32/qt5-static/bin/qmake.exe -config release
make -j 4
strip projects/cli/cutechess-cli.exe
strip projects/gui/cutechess.exe
zip -j9 ../cutechess-cli-win.zip COPYING projects/cli/cutechess-cli.exe

64 bit version

  1. start a MSYS2 MinGW 64-bit console
  2. write and start this script:
#!/bin/bash
# http://stackoverflow.com/a/34001073/1583123

# update and install packages
pacman -S --noconfirm git make zip mingw-w64-x86_64-gcc mingw-w64-x86_64-jasper mingw-w64-x86_64-zstd mingw-w64-x86_64-qt5-static

# build cutechess-cli and cutechess
git clone https://github.com/cutechess/cutechess.git
cd cutechess

# checkout the latest tag
git fetch -p --tags --all
tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $tag -b latest

git log --oneline -n 5 > ../cutechess.git.log
/mingw64/qt5-static/bin/qmake.exe -config release
make -j 4
strip projects/cli/cutechess-cli.exe
strip projects/gui/cutechess.exe
zip -j9 ../cutechess-cli-win-64bit.zip COPYING projects/cli/cutechess-cli.exe

Linux

Use Ubuntu 14.04 (32 bit and 64 bit) to build cutechess-cli for fishtest, in order to link the older versions of shared libraries. cutechess-cli tested working with several Linux distro (Ubuntu, CentOS, Debian, Fedora, OpenSuse, Arch, Gentoo, Clear Linux) and Windows Subsystem for Linux.

Write and start this script:

#!/bin/bash
# sudo bash make_cute.sh
# https://wiki.qt.io/Building_Qt_5_from_Git
# http://doc.qt.io/qt-5/linux-deployment.html

n_jobs=6

# update and install packages
apt update && apt full-upgrade -y
sudo apt-get -y build-dep qt5-default
apt install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
apt install -y build-essential perl python git zip

# build Qt5 static
git clone https://code.qt.io/qt/qt5.git
cd qt5
git checkout 5.10
perl init-repository --module-subset=default,-qtwebengine
mkdir /opt/qt5-static
./configure -static -release -opensource -confirm-license -prefix /opt/qt5-static -nomake examples -nomake tests -nomake tools -skip qtwebengine -no-icu
make -j ${n_jobs}
make -j ${n_jobs} install

# build cutechess-cli and cutechess
cd
git clone https://github.com/cutechess/cutechess.git
cd cutechess

# checkout the latest tag
git fetch -p --tags --all
tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $tag -b latest

# comment out the Qt version check
sed -i '1,4{s/^/##/}' cutechess.pro

git log --oneline -n 5 > ../cutechess.git.log
/opt/qt5-static/bin/qmake -config release
make -j ${n_jobs}
strip projects/cli/cutechess-cli
strip projects/gui/cutechess
zip -j9 ../cutechess-cli-linux-$(getconf LONG_BIT)bit.zip COPYING projects/cli/cutechess-cli

Use this script to test the linux cutechess-cli binaries with some major linux distributions:

#!/bin/bash
# use lxc/lxd on Ubuntu 18.04 or later
# sudo snap install lxd
# sudo lxd init
# accept all the defaults
# copy cutechess-cli binaries in "32" and "64" folders

_test_cute () {
echo ${1} ${2}
lxc launch ${1} c000
lxc file push ${2}/cutechess-cli c000/root/cutechess-cli
[[ -z ${3} ]] || lxc exec c000 -- bash -c "${3}"
lxc exec c000 -- ldd cutechess-cli
lxc exec c000 -- ./cutechess-cli --version
lxc delete -f c000
}

_test_cute ubuntu:14.04 64
_test_cute ubuntu:16.04 64
_test_cute ubuntu:18.04 64
_test_cute ubuntu:20.04 64

_test_cute images:centos/6 64
_test_cute images:centos/7 64
_test_cute images:centos/8 64

_test_cute images:archlinux 64

_test_cute images:opensuse/15.1 64
_test_cute images:opensuse/15.2 64

# debian requires libglib2.0-dev
cmd_str="apt update && apt install -y libglib2.0-dev"
_test_cute images:debian/9 64 "${cmd_str}"
_test_cute images:debian/10 64 "${cmd_str}"
_test_cute images:debian/11 64 "${cmd_str}"

# gentoo requires libglib2.0-dev
cmd_str="emerge dev-libs/glib"
_test_cute images:gentoo 64 "${cmd_str}"

_test_cute images:fedora/31 64
_test_cute images:fedora/32 64

_test_cute ubuntu:14.04/i386 32
_test_cute ubuntu:16.04/i386 32
_test_cute ubuntu:18.04/i386 32

_test_cute images:centos/7/i386 32