Belofte  version 2.1.5
A promising chess program using the UCI or Winboard interface
Compiling

How to compile, debug and test Belofte

This is the Building/Compiling/Debugging file for belofte, a promising chess program released under GNU - GPL v2.0.

Please refer to the manual for more information on using the program.


Building/Compiling/Debugging

If the binaries for your platform are not released, or you want to create a custom build, you need to compile from source. Your toolset needs to support C++11. See C++ reference for more information.

Overall compile instructions

Compile with make

cd project
make all

Compile with compile script

preferred method

cd project
./compile.sh [--gcc|--clang|--cross] [--opt|--profile] [--32|--64|--all] [next]
  • --gcc: prefer gcc complier;
  • --clang: prefer clang compiler;
  • --cross: cross compile with mingw from linux to windows;
  • --opt: also generate optimized build (32/64) and a static build (64) for your machine;
  • --profile: build non optimized profilable build;
  • --32: build 32 bit target only;
  • --64: build 64 bit target only;
  • --all: build 32 and 64 bit (on 64 bit platform) please note building 64 bit on 32 bit platform is not possible;
  • next: if not passed, will detect version number from source code.

Compile with Cmake

Cmake is not supported yet.

cd project
Cmake all

Linux compile instructions

By default, your platform is only configured to compile compatible programs. Therefore, on a 64 bit system, 32 bit compilation must be enabled manually first. See below. Not doing so will result in an error during compilation that can be ignored.

  • Compiling on Linux x64 for 32 or 64 bit with Clang or GCC installed, use compile.sh.

Make sure static libraries are available, alongside gcc and clang.

dnf install g++ clang
dnf install glibc-static libstdc++-static
# following is required for Fedora 35
dnf install libstdc++-static.x86_64
  • Installing GCC and Clang 32 target compilation on 64 bit Linux:
dnf install glibc-devel.i686 libstdc++-devel.i686
dnf install glibc-static.i686 libstdc++-static.i686

Replace dnf with yum/apt-get/... according to your linux flavour. Use sudo if required.

  • Compiling on Linux x86_64 with Code::Blocks installed: Open Code::Blocks project file, select target and build all or debug.
  • Compiling on Linux with NetBeans installed: Open NetBeans 8.02 or NetBeans 8.2, compile or debug.

Linux cross compile to windows instructions

Install the cross compiler and compile. See below example for Fedora 34.

dnf install mingw32-gcc mingw32-gcc-c++ mingw64-gcc mingw64-gcc-c++
dnf install mingw32-winpthreads-static mingw64-winpthreads-static
cd project
./compile.sh --cross --all

See below example for Ubuntu 21.10. (still issue with std::thread not supported)

apt update
dpkg --add-architecture i386
apt install libc++-dev libc++-dev:i386
apt install binutils-mingw-w64 g++-mingw-w64
apt autoremove

Mac OS X compile instructions

  • Compiling on Mac OS X with developer command line tools for Xcode installed, use compile.sh.
./compile.sh --64

Windows compile instructions

  • Compiling on Windows 64-bit with Code::Blocks installed: Open Code::Blocks project file, select target and build all or debug.
  • Compiling on Windows with Dev C++ installed: Open Dev C++ project (.dev) and build all. (warning, creates slow executable due to bundled gcc version.)
  • Compiling on Windows with other compilers: Compiler needs to support C++11, This means that following compilers will not work: Visual Studio Express, versions before Visual Studio 2015, Visual Studio Code, Borland C++ builder, Borland C++, ...

You cannot run or debug 64 bit code on a 32 bit platform.

Android compile instructions

  • Android builds are generated with ndk-build from Android NDK r22 Beta 1.
cd project/ndk-build
make

ReactOS compile instructions

  • Install the Code::Blocks from the repository: Open Code::Blocks project file, select target w32 and build. Running not yet possible though.

Configuring belofte

When compiling, following conditionals (#define) can be turned on or passed as -D parameter in the compile script. See project/compile.sh for more details.

  • BELOFTE_NORANDOM: set modus to no random by default, evaluation will never add random;
  • BELOFTE_UCIMODE: creates a binary that defaults to UCI protocol;
  • BELOFTE_NOSIGNALS: suppress reaction to signals. (SIGINT, SIGTERM);
  • BELOFTE_NOUNICODE: compile for platforms that do not support UTF-8 console output, defined for all targets in release mode;
  • INCOMPLETE_C11: compile with compiler that does not support full C++11, defined for GCC before version 6;
  • CHRONO_MISSING: compile on platform that does not have <chrono> header;
  • NODIRENT: compile on platform that does not have dirent.h or that lacks runtime support for it (e.g. cross compiler);

Testing your compile

After compilation, it is always good to test if your conpile is correct. For this a numer of test suites are available.

Validating if no errors were introduced

Belofte supports epd to test a position. Launch epd pos, epd file commands with valid epd strings. Please refer to the documentation for more information.

cd test
./belofte.sh belofte bmi2 2.1.4
belofte>epd file epd/perftsuite.epd

Belofte also supports executing commands from a command file. Use exec to run a test.

cd test
./belofte.sh
belofte>exec testcase/perft01.rc

Speed tests

Run benchmark:

cd test
./belofte.sh belofte 2.1.4 --bench
./belofte/dist/Linux-x86-64/belofte-2.1.4 bench

Run benchmark against specific compile (i.e. GCC popcnt):

cd project
./compile.sh --gcc --opt --all
cd ../test
./belofte.sh belofte 2.1.4 --bench
./belofte.sh belofte 2.1.4 32 --bench
./belofte.sh belofte popcnt 2.1.4 --bench

Cross platform tests

Run windows (32/64 bit) executable from linux through wine:

cd test
./belofte.sh wine belofte32-2.1.4.exe 32 --info --quit
./belofte.sh wine belofte-2.1.4.exe 64 --version

eof