Notice: Trying to access array offset on value of type bool in /home/customer/www/flogvit.com/public_html/wp-content/themes/Divi/includes/builder/functions.php on line 2442
Running stockfish or komodo on Centos 6 | Flogvit

I wanted to try out a chess engine, but I didn’t want to run it on my own computer where I have the GUI. So what to do? I had a centos 6 computer with enough cpu power, but when I downloaded and ran stockfish I got:

$ ./stockfish-7-linux/Linux/stockfish\ 7\ x64 
./stockfish-7-linux/Linux/stockfish 7 x64: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./stockfish-7-linux/Linux/stockfish 7 x64)
./stockfish-7-linux/Linux/stockfish 7 x64: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by ./stockfish-7-linux/Linux/stockfish 7 x64)

And when I ran komodo 10.1 (which you have to buy), I got:

$ ./komodo-10.1-linux 
./komodo-10.1-linux: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./komodo-10.1-linux)
./komodo-10.1-linux: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./komodo-10.1-linux)

The problem is Centos 6 has too old glibc version. So how to fix this? The short version is to download the finished files I’ll show you how to create in the long answer. They are ld-linux-x64-64.so.2, libc.so.6 and libstdc++.so.6.

Short answer:

wget http://www.menneske.no/libs/chesslib.tar.gz
tar zxvf chesslib.tar.gz
./ld-linux-x86-64.so.2 --library-path . <path to komodo or stockfish>

Voila, they both works fine on Centos 6.

Long answer:
For stockfish you can download the src and compile it. But for komodo that is not possible. So, you need to compile both gcc and glibc to be able to get the files. It takes a long time, and some GB of space, but here is how you do it, if you don’t trust my precompiled files:

# First we assure we have the development tools to build stuff
yum groupinstall "Development tools"
yum install -y glibc-devel glibc-i686

# Now we build glibc. This will not overwrite your current glibc, so don't worry
cd /tmp
wget http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
tar -xvzf glibc-2.17.tar.gz
cd glibc-2.17
mkdir glibc
cd glibc
../configure --prefix='/opt/glibc-2.17'
make
make install

# Then compile gcc
cd /tmp
wget ftp://ftp.gwdg.de/pub/misc/gcc/releases/gcc-4.6.4/gcc-4.6.4.tar.gz
tar -xvzf gcc-4.6.4.tar.gz
cd gcc-4.6.4
./contrib/download_prerequisites
mkdir objdir
cd objdir
../configure --prefix=/opt/gcc-4.6.4
make
make install

Now we have all the files, and we copy them out to our preferred directory.

cd <your path>
cp /opt/gcc-4.6.4/lib64/libstdc++.so.6 .
cp /opt/glibc-2.17/lib/libc.so.6 .
cp /opt/glibc-2.17/lib/ld-linux-x86-64.so.2 .

And then you run it with:

./ld-linux-x86-64.so.2 --library-path . <path to komodo or stockfish>

But how did I reach it from my other computer? Well, ssh to the resque.

cat <<EOT > komodo
#!/bin/sh
# ssh chess.test.com -l chess ./ld-linux-x86-64.so.2 --library-path . <path to komodo or stockfish>
ssh <yourhost> -l <youruser> <path to komodo on host>
EOT

# fix permissions
chmod 750 komodo

Remember to add pub ssh key to the host, so you don’t need to write the password to login. Voila, then you just add “komodo” as the engine in your favourite GUI.

%d bloggers like this: