Skip to content

How to Compile libxayagame in Ubuntu short

Ryan edited this page Mar 8, 2019 · 6 revisions

How to Compile libxayagame in Ubuntu

In this tutorial, we'll compile libxayagame in Ubuntu so that we can use it in other tutorials and even in our own games.

This tutorial assumes a fresh install of Ubuntu 18.04.02 (Bionic Beaver). You can get a VirtualBox VM of that here. Others may need to tweak some portions or to use a different installation method.

Install Prerequisites and Dependencies

The following will install most prerequisites and dependencies for you. Copy and paste this in your terminal:

sudo apt-get install build-essential autoconf-archive cmake-curses-gui libtool pkg-config git libjsoncpp-dev libjsonrpccpp-dev libjsonrpccpp-tools libzmq3-dev libsqlite3-dev liblmdb-dev libgoogle-glog-dev libssl-dev

Install gflags

You cannot use sudo apt-get install libgflags-dev to install gflags because it does not include pkg-config, which libxayagame requires.

You must build from source.

Refer to the official instructions here:

https://github.com/gflags/gflags/blob/master/INSTALL.md

Once you've completed that, return back here and continue.

Install gtest

Installing gtest only installs the source files. You must then compile the code yourself. The following instructions are from here:

https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/

sudo apt-get install libgtest-dev
sudo apt-get install cmake 
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo cp *.a /usr/lib

When you compile libxayagame, it must know where to look for gtest.

export GTEST_CFLAGS="/usr/src/gtest"
export GTEST_LIBS="/usr/src/gtest"

You can also enter the location of the gtest libraries into /etc/environment.

echo 'export GTEST_CFLAGS="/usr/src/gtest"' >> ~/.profile
echo 'export GTEST_LIBS="/usr/src/gtest"' >> ~/.profile

Copy and paste the following on a new line.

GTEST_CFLAGS="/usr/src/gtest"
GTEST_LIBS="/usr/src/gtest"

Save the file and exit.

Note: Installing gtest also installs gmock.

Install protobuf

We must build protobuf from source as we did for gtest above.

It will take quite some time to compile, so get a beverage and a book to read, or perhaps a YouTube video to otherwise keep yourself occupied/entertained.

In your browser or with wget, download a "cpp" bundle (there are other versions, such as "csharp" and "java", but we're using C++, so make certain to get the proper "cpp" download), such as "protobuf-cpp-3.7.0-rc-3.tar.gz" from this page:

https://github.com/protocolbuffers/protobuf/releases

Extract the contents of the file into ~/Downloads/protobuf/ and navigate into that folder in your terminal.

cd ~/Downloads/protobuf

Make sure that you didn't extract the extra directory depth and that the files are in that folder.

Compiling will take some time.

./configure
make
sudo make install
sudo ldconfig
protoc --version

And now... on to libxayagame!

Install libxayagame

We've not got all our dependencies installed and ready. It's time to get started with libxayagame!

Clone the libxayagame repository there and then navigate into it.

git clone https://github.com/xaya/libxayagame.git
cd ~/Downloads/libxayagame	
./autogen.sh && ./configure && make && sudo make install && sudo ldconfig

CONGRATULATIONS!

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

Clone this wiki locally