Skip to content

How to Compile libxayagame in Ubuntu

Renegade edited this page Nov 16, 2021 · 1 revision
Clone this wiki locally

How to Compile libxayagame in Ubuntu 20.04.3

This will help you to compile libxayagame in Ubuntu so you can use it in other tutorials and in your own games.

Most dependencies can simply be installed, but some you will need to build and install from source.

You can optionally download the install-libxayagame.sh script and run it. It runs the same commands as below, but will prompt you to continue at each new stage.

Prepare to Build and Install libxayagame

The following build instructions assume a fresh installation of Ubuntu 20.04.3 LTS.

NOTE: For the most current information, refer to the libxayagame repository here:

https://github.com/xaya/libxayagame

Update and Upgrade Ubuntu

sudo apt-get -y update

You can upgrade, but it's not required, and was not used for this build.

sudo apt-get upgrade

Install Prerequisites & Dependencies with apt

The following will install most dependencies for you. Some others must be built from source.

sudo apt-get -y install build-essential libargtable2-dev libzmq3-dev zlib1g-dev libsqlite3-dev liblmdb-dev libgoogle-glog-dev libgflags-dev libprotobuf-dev protobuf-compiler python3 python-protobuf autoconf autoconf-archive automake cmake git libtool pkg-config libcurl4-openssl-dev libssl-dev libmicrohttpd-dev make

Build and Install JSONCPP from Source

libxayagame requires JSONCPP v1.7.5 or higher, but only v1.7.4 is available to install via apt.

Further, the build process is somewhat odd, so make certain to follow the instructions below, or ensure that any changes you make don't break the libxayagame build process.

Specifically, v1.9.4 has a broken pkg-config file which must be specifically fixed. The following is currently a "hack" until a new version is released. You can refer to https://github.com/xaya/libxayagame/blob/ubuntu-build/Dockerfile for version updates.

cd ~/
mkdir jsoncpp && cd jsoncpp
git clone -b 1.9.4 https://github.com/open-source-parsers/jsoncpp .
git config user.email "test@example.com"
git config user.name "Cherry Picker"
git cherry-pick ac2870298ed5b5a96a688d9df07461b31f83e906
cmake . -DJSONCPP_WITH_PKGCONFIG_SUPPORT=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF
make -j4
sudo make install/strip

Build JSON-RPC-CPP from Source

JSON-RPC-CPP must be built from source because the available packages are not fresh enough. Specifically, they must include commit 4f24acaf4c6737cd07d40a02edad0a56147e0713.

cd ~/
git clone https://github.com/cinemast/libjson-rpc-cpp
cd libjson-rpc-cpp
cmake . -DREDIS_SERVER=NO -DREDIS_CLIENT=NO -DCOMPILE_TESTS=NO -DCOMPILE_EXAMPLES=NO -DWITH_COVERAGE=NO
make -j4
sudo make install/strip

Build Googletest from Source

googletest must be built from source.

cd ~/
git clone https://github.com/google/googletest
cd googletest
cmake .
make -j4
sudo make install/strip

Install ZMQ C++ Bindings from Source (CPPZMQ)

The following will install the ZMQ C++ bindings.

cd ~/
git clone -b v4.7.1 https://github.com/zeromq/cppzmq
cd cppzmq
sudo cp zmq.hpp /usr/local/include

Clean Up and Make All Installed Dependencies Visible

The following is a clean-up step and will make our installed dependencies visible for when we build libxayagame.

sudo ldconfig

Build libxayagame

With the above accomplished, building and installing libxayagame is simple and straight forward.

cd ~/
git clone https://github.com/xaya/libxayagame.git
cd ~/libxayagame
./autogen.sh
./configure
make -j4
sudo make install

Clean Up and Make libxayagame Visible

Similar to the clean-up step above, this does the same and will make libxayagame visible for when you write your GSP.

sudo ldconfig

CONGRATULATIONS!

Congratulations! You've just built and installed libxayagame. You can now proceed on to the Hello World in C++ tutorial where we'll put libxayagame to good use!

Update libxayagame

We update libxayagame periodically. If you wish to update your build, enter the following into a terminal.

cd ~/libxayagame
git pull
make clean
./autogen.sh
./configure
make -j4
sudo make install
sudo ldconfig

You're now up-to-date with the latest version!

NOTE: Should the update build break, refer to the libxayagame repository as it is always up-to-date:

https://github.com/xaya/libxayagame

You can also refer to the libxayagame Docker build file for further specifics:

https://github.com/xaya/libxayagame/blob/ubuntu-build/Dockerfile