How to Build Zetacoin

Zetacoin is another SHA-256 crypto-currency based on Bitcoin. It's only been around since August 2013 and it's mining difficulty (as of Nov 2013) is not yet as insanely high as Bitcoin. Zetacoins have some value in the market, but I think I'll hold on to mine for the time being. I wanted to get a Zetacoin node running alongside my Bitcoin and Litecoin nodes. After a few failures I determine it's currently not possible (at least with what I know) to build Zetacoin on FreeBSD.

UPDATE: It's possible to build Zetacoin on FreeBSD, see http://www.unibia.com/unibianet/freebsd/install-zetacoin-freebsd

The error I am getting is:

obj/bitcoind.o: In function `main':
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:127: multiple definition of `main'
obj-test/test_bitcoin.o:/usr/local/include/boost/test/unit_test.hpp:57: first defined here
obj/bitcoind.o: In function `AppInit(int, char**)':
bitcoind.cpp:(.text+0x799): undefined reference to `Shutdown()'
bitcoind.cpp:(.text+0xc07): undefined reference to `HelpMessage()'
bitcoind.cpp:(.text+0xfbd): undefined reference to `AppInit2(boost::thread_group&)'
bitcoind.cpp:(.text+0x102e): undefined reference to `Shutdown()'
obj/bitcoind.o: In function `DetectShutdownThread(boost::thread_group*)':
bitcoind.cpp:(.text+0x1aa8): undefined reference to `ShutdownRequested()'
bitcoind.cpp:(.text+0x1ac1): undefined reference to `ShutdownRequested()'
gmake: *** [test_zetacoin] Error 1
gmake: Leaving directory `/root/zetacoin/work/zetacoin-zetacoin-5eed859/src'

I was able to fix part of the error by modifying the Makefile and adding "-DBOOST_TEST_NO_MAIN" to the "TESTDEFS" line:

TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) -DBOOST_TEST_NO_MAIN

Unfortunately I am still left with this error:

obj/bitcoind.o: In function `AppInit(int, char**)':
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:43: undefined reference to `Shutdown()'
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:57: undefined reference to `HelpMessage()'
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:102: undefined reference to `AppInit2(boost::thread_group&)'
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:121: undefined reference to `Shutdown()'
obj/bitcoind.o: In function `DetectShutdownThread(boost::thread_group*)':
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:12: undefined reference to `ShutdownRequested()'
/root/zetacoin/work/zetacoin-zetacoin-5eed859/src/bitcoind.cpp:17: undefined reference to `ShutdownRequested()'

I'm not a C++ programmer so I admit defeat.

Lets try Centos

I always try to use FreeBSD for everything I do, but due to the non-portable nature of Unix/Linux applications this is not always possible. In fact it's wrong to assume that every Linux distribution is Unix and all applications will work between the different distros, releases, and versions.

So I decide that, okay, perhaps Zetacoin was developed to be Linux only. The next best thing to FreeBSD in the Linux world is Centos. I get minimal Centos running on my VMware Vsphere cluster. I begin by installing all the dependencies needed for building.

Oh no!

yum install libdb4.8-dev -y
Setting up Install Process
No package libdb4.8-dev available.
Error: Nothing to do

Turns out that there are no Centos packages for libdb4.8-dev. Failing to install this library will result in the following compiler error:

"headers.h:36:20: fatal error: db_cxx.h: No such file or directory"

Less progress was made with Centos. What's next?

Ubuntu

Much to my disgust and as much as I hate and want to avoid it. I fear I must use Ubuntu. I don't hate Ubuntu, it's a good Linux and I've used it in the past. In fact, this website run's on a old Ubuntu server I have yet to migrate to FreeBSD. My problem with Ubuntu is that it's over complicated and breaks bad when it breaks.

I decide to give the latest and greatest Ubuntu Server a chance and get version 13.10 running on the VMWare cluster. It's been a while since I installed Ubuntu server. The process was quite pleasing and much to my surprise it boots pretty darn fast!

Oh! but not AGAIN!

sudo apt-get install libdb4.8-dev
Reading package lists... Done
Building dependency tree

Reading state information... Done
Package libdb4.8-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libdb4.8-dev' has no installation candidate

Same issue and as it turns out there are no packages available for the latest and greatest. But hey, according to Ubuntu's website, they exist for 12.04. So I decide to downgrade to 12.04 LTS. After about 1 hour I have Ubuntu 12.04 LTS running on my VMware cluster and I finally got that libdb4.8-dev dependency installed. I proceed to install the next one.

sudo apt-get install libdb4.8++-dev
Reading package lists... Done
Building dependency tree

Reading state information... Done
Package libdb4.8++-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libdb4.8++-dev' has no installation candidate

SERIOUSLY???

No package exists for libdb4.8++-dev (aka the C++ library to db4.8). By this time I have wasted a whole day just getting dependencies worked out. This is a reason why I prefer FreeBSD.

Digging deeper I see that Ubuntu 10.04.3 LTS has all the packages I need. It's kind of ironic, since 10.04.3 is that last time I used Ubuntu in production. Kind of sad that I have to use an operating system that is over 3 years old. This is what I mean when not all Linux's are the same.

Finally it Builds

I'm happy to report that Zetacoin builds and runs without any trouble on Ubuntu 10.04.3, but not without some extra steps. Here is what I did to get it working on a VMware Guest (all done as root):

Apply any Updates

apt-get update
apt-get upgrade
reboot

Install VMware Tools

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
ls /mnt/cdrom
tar xzvf /mnt/cdrom/VMwareTools-9.0.0-782409.tar.gz -C /tmp/
cd /tmp/vmware-tools-distrib/
./vmware-install.pl -d
reboot

Install the Dependencies

apt-get install build-essential
apt-get install libssl-dev
apt-get install libdb4.8-dev
apt-get install libdb4.8++-dev
apt-get install libboost-all-dev
apt-get install git-core
apt-get install ntp

Download Zetacoin Source, Build, and Install

cd /usr/local/
git clone https://github.com/zetacoin/zetacoin.git
cd zetacoin/
cd src/
make -f makefile.unix USE_UPNP=
strip zetacoind
cp zetacoind ..

To properly run a Zetacoin node you'll need both a configuration file and a startup script. The configuration file is very simple:

rpcuser=admin
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXX
maxconnections=300
rpcallowip=127.0.0.1
rpcallowip=192.168.0.*
rpcport=17335
port=17333
addnode=63.247.147.163:27333
server=1
daemon=1
listen=1
logtimestamps=1

Save that file as /etc/zetacoin.conf.

Next comes the complicated part, the service start and stop scripts. Again, this is another area that FreeBSD simply excels in and Linux fails. In Ubuntu the service scripts are very over complicated. Luckily for you, you can just download and install these pre-made scripts.

First create a file named: /etc/default/zetacoin with the following content:

ENABLE=yes

SERVER_CONF=/etc/zetacoin.conf
DATADIR=/var/db/zetacoin
RUNUSER=root
RUNGROUP=wheel

NICE_VAL=18

Next download the INIT script and save it to /etc/init.d/zetacoin and issue the following commands to properly set up things:

mkdir -p -m 777 /var/db/zetacoin
chmod +x /etc/init.d/zetacoin

Or just copy and paste each line below into your console to have it all done automatically:

wget -qO /etc/init.d/zetacoin http://www.unibia.com/unibianet/sites/default/files/zetacoin-init.txt 
wget -qO /etc/default/zetacoin http://www.unibia.com/unibianet/sites/default/files/zetacoin-default.txt
wget -qO /etc/zetacoin.conf http://www.unibia.com/unibianet/sites/default/files/zetacoin-conf.txt
mkdir -p -m 777 /var/db/zetacoin
chmod +x /etc/init.d/zetacoin

You should be able to start, stop, and check the status of the Zetacoin service with these commands:

service zetacoin stop
service zetacoin start
service zetacoin status

If you want to get a Stratum Pool Server going save yourself the trouble and just use FreeBSD. Ubuntu 10.04.3 uses Python 2.6 and you need Python 2.7.