Ubuntu 12.10でCadiaPlayer3.0を動かすまでの道のり

General Game Playing Competitionで3回優勝しているCadiaPlayerは動かすまでが結構面倒なので,その手順をメモしておきます.

環境

Ubuntu 12.10
GCC 4.7.2
Boost 1.49.0

YAP Prologのインストール

$ cd
$ git clone git://yap.dcc.fc.up.pt/yap-6
$ cd yap-6
$ ./configure
configure: error: --with-readline was given, but test for readline failed

configureでエラーが出る.config.logを見てみると,

/usr/bin/ld: cannot find -lreadline
/usr/bin/ld: cannot find -lncurses

libreadlineとlibncursesが見つからないと言っているのでインストールする.

$ sudo apt-get install libreadline-dev libncurses5-dev

これでconfigureが通るようになる.

$ ./configure
$ make
$ sudo make install

CadiaPlayerのビルド

$ cd
$ wget http://cadia.ru.is/wiki/_media/public:cadiaplayer:cadiaplayer-3.0.tar.gz -O cadiaplayer-3.0.tar.gz
$ tar zxvf cadiaplayer-3.0.tar.gz
$ cd cadiaplayer-3.0
$ ./configure
configure: error: GNU MP not found, see http://gmplib.org/

./configureでエラーが出る.libgmpをインストールする.

$ sudo apt-get install libgmp-dev

これで./configureが通るようになる.

$ ./configure
$ make
/bin/bash: flex: command not found

flexをインストールする.

$ sudo apt-get install flex

再びmake.

$ make
g++ -DHAVE_CONFIG_H -I. -I..   -I/usr/include -Wno-deprecated  -g -O2 -O3 -MT gmprotocol.o -MD -MP -MF .deps/gmprotocol.Tpo -c -o gmprotocol.o gmprotocol.cpp
gmprotocol.cpp: In static member function ‘static bool cadiaplayer::agent::GMProtocol::hasMessage()’:
gmprotocol.cpp:8:20: error: ‘STDIN_FILENO’ was not declared in this scope

エラーメッセージで検索してみると,どうやらunistd.hをインクルードするといいらしい.
Bug #976551 “ftbfs with gcc 4.7 if not including <unistd.h>” : Bugs : widelands
doesn't compile with gcc 4.7 (?) - Technical Help - Forum - Widelands.org
agent/gmprotocol.cppに#include を書き足して再びmake.

$ make
cadiaplayer.o: In function `~posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference to `pthread_key_delete'

リンク時にエラーが発生する.-pthreadオプションを使うようにconfigureをやり直して再びmakeすると通る.

$ ./configure LIBS="-pthread"
$ make
$ make install

これでビルド完了.お疲れ様でした.