This research has meant having to spin up test virtual machines and since Ubuntu 16.04 is my server OS of choice (the 64-bit LTS server version) here’s how I’ve setup a Namecoin node.
Your results may vary, and I make no promises or guarantees on the outcome of these steps, other than to say it worked for me.
You’ll need to start with a freshly installed Ubuntu 16.04 LTS 64-bit server (in my case running on a VMWare hypervisor with 2 x CPU, 2048 Gb RAM, 48 GB HDD; hardware/platform is up to you).
I simply installed it from scratch, creating a user account for myself, changed the IP address to a static configuration (I have instructions for that here) and also did a full update and reboot.
sudo apt-get update && sudo apt-get -y upgrade && sudo reboot
The steps following assume you have SSH’d into the box (or at the console) using your own account.
Although I do have a bad habit of using “sudo -i” to get a root prompt, when it comes to building projects from source code I always stick to using my own account.
Step 1. Install required libraries
There are a bunch of packages you’ll need to install, the most important of which begins with all the essential build tools included in the “build-essential” package.
sudo apt-get install build-essential
Then there are a bunch of other packages you’ll need later on, I compiled this list from trial-and-error the first time I did this.
sudo apt-get install autoconf libtool pkg-config sudo apt-get install libboost-all-dev libssl-dev libevent-dev
Step 2. Download the namecoin-core
cd ~ git clone https://github.com/namecoin/namecoin-core.git
This will retrieve a clone of the git repository that contains the latest version of the namecoin-core project.
I simply run this from my home folder and it creates a namecoin-core/ folder in my home directory. I know some people like to put source code into /usr/src and other such places, but since this is a single purpose built test-server I don’t bother.
We’re not going to do anything with this just yet, but you’ll need it in the next step.
Step 3. Getting BerkeleyDB 4.8 libs
This was a stumbling block that I encountered caused due to Ubuntu 16.04 being so new. I kept getting this error during the configuration of the namecoin build.
If you have no version of Berkeley DB installed:
checking for Berkeley DB C++ headers… no
configure: error: libdb_cxx headers missing, Namecoin Core requires this library for wallet functionality (–disable-wallet to disable wallet functionality)
Or if you’ve somehow already installed libdb++-dev (or libdb5.3++-dev) which you’ll need to apt-get remove to proceed further:
checking for Berkeley DB C++ headers… default
configure: error: Found Berkeley DB other than 4.8, required for portable wallets (–with-incompatible-bdb to ignore or –disable-wallet to disable wallet functionality)
Let me quickly explain what this is all about.
Namecoin, like Bitcoin, provides a wallet for your coins. This functionality is provided by storing encryption keys in a special file called “wallet.dat” – which is a Berkeley DB file (a type of file-based database), and in the early days of Bitcoin it was the 4.8 library version that was originally used.
The problem is that Ubuntu 16.04 is created to only provide a package for the Berkeley DB library 5.3 and while this would normally be fine, it means your wallet.dat file would not work on other systems if you were to move it elsewhere.
Once a Berkeley DB file (i.e. wallet.dat in this case) is accessed by a program using a later version of the Berkeley DB library the file being accessed is upgraded automatically – and the file can never be converted back to the previous version. Hence, most wallet.dat files are using 4.8 so we should probably stick to that for peace of mind.
The solution at it turns out isn’t that hard, like most things when you eventually find the correct answer!
If this download doesn’t work, maybe visit the Oracle website and find the link that does.
tar xzvf db-4.8.30.NC.tar.gz cd db-4.8.30.NC/build_unix/ ../dist/configure --enable-cxx make sudo make install
My sincere thanks to the discussion on this Github page for the steps above.
In addition to compiling and installing the Berkeley DB 4.8 lib, I still had issues and had to create the following symbolic links so the headers and lib files could be found. Thanks to the thread here for that.
sudo ln -s /usr/local/BerkeleyDB.4.8 /usr/include/db4.8 sudo ln -s /usr/include/db4.8/include/* /usr/include sudo ln -s /usr/include/db4.8/lib/* /usr/lib
Once you have compiled and installed the Berkeley DB 4.8 library from source, you now need to edit a file in the namecoin-core source to help it find the header files that are needed for the compile of Namecoin.
cd ~/namecoin-core/ nano build-aux/m4/bitcoin_find_bdb48.m4
Look for the line starting with bdbdirlist= and add the full path to that /build_unix/ folder from earlier. In my case it was in /home/mjm/db-4.8.30.NC/build_unix but it will no doubt be different for you.
Step 4. Compiling namecoin-core
Now we being with the build of the namecoin-core binaries.
cd ~/namecoin-core/ ./autogen.sh ./configure make sudo make install
Note that these steps may take some time, especially the make command above – it took about ten minutes or so for me.
Once this is complete you’ll have the following files in your /usr/local/bin/ ready to go.
You’ll want to start up namecoind to run in the background and in a separate article I’ll cover the best-practice of using systemd to keep that up and running in the background.
You should also create a separate ‘namecoin’ user with less privileges to run the namecoind daemon.
Hopefully this has been some help to you.