How to Compile Bitcoin Source Code in Ubuntu 16.04 LTS

If you are building some projects around bitcoin then you might have realized that you have to compile the bitcoin source code to create the bitcoind for your own machine. This is necessary because sometimes the pre-compiled binary do not work as expected and your whole project might become erroneous. It is far better to compile bitcoin by your own and then use it.

Advertisements
World is looking for a Certified Blockchain Expert Become one

How to Compile Bitcoin Source Code in Ubuntu 16.04 LTS

In this post, I will explain how to compile bitcoin source code on Ubuntu 16.04 LTS. I will be running my Ubuntu instance on AWS though you can follow the same instructions anywhere on Ubuntu 16.04 LTS.

Please make sure your server has at least 4 GB of RAM. I am assuming the username is “ubuntu” (without double quotes) but if your username is something else like root, mark, etc. then please replace ubuntu accordingly.

# Update & Upgrade the System
sudo apt-get update
sudo apt-get upgrade

# Install dependencies there might be more based on your system
# However below instructions are for the fresh Ubuntu install/server
# Please carefully watch the logs because if something could not be install
# You have to make sure it is installed properly by trying the command or that particular
# dependency again

sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
sudo apt-get install libqrencode-dev autoconf openssl libssl-dev libevent-dev
sudo apt-get install libminiupnpc-dev

# Download Bitcoin Source code
# ----------------------------
cd ~
git clone https://github.com/bitcoin/bitcoin.git

# Bitcoin uses the Berkley DB 4.8
# We need to install it as well
# Download & Install Berkley DB
# -----------------------------
cd ~
mkdir bitcoin/db4/
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/home/theusername/bitcoin/db4/
make install

# Compile Bitcoin with Berkley DB 4.8
# -----------------------------------
cd ~/bitcoin/
./autogen.sh
# below command ./configure may return with error for dependencies
# you need to make sure that it returns with no error
# If it does please install the dependencies and rerun the /autogen.sh command again and then below command again
./configure LDFLAGS="-L/home/theusername/bitcoin/db4/lib/" CPPFLAGS="-I/home/theusername/bitcoin/db4/include/"

# below command may take 5-10 minutes based on your system
make -s -j5

# If all went well you will be able to access the binary at below location
cd ~/bitcoin/
./src/bitcoind
./src/bitcoin-qt
./src/bitcoin-cli

If you have any questions or any bug to report please comment below.

 

  • rnd

    running ./autogen.sh got me:
    Can’t exec “aclocal”: No such file or directory at /usr/share/
    Fixed this by installing automake
    sudo apt-get install automake

    also had to install libdb++
    sudo apt-get install libdb++-dev

  • rnd

    also needed the following:
    sudo apt-get install bsdmainutils

  • Need to develop the bitcoin wallet app Development. https://www.brsoftech.com/cryptocurrency-development.html

  • Thanks for sharing such good information.

    What Actually is Cryptocurrency?
    It basically means no one can update the database without fulfilling few specific needs. Any cryptocurrency like bitcoin has a network of peers. Owebest is one stop cryptocurrency development Company in India.

  • UgochukwuEmmanuelAgbams

    How or at which directory should I create of find bitcoin.conf file for editing? In addition, how do I backup my bitcoin should incase of system crash?

  • john mary

    Bitcoin today is used by many merchants, be it air travel agency, online retail store, restaurants and so on. The list of merchants accepting bitcoin is payment is constantly growing. It is the safest way of paying goods and services in the global marketplace. If you are looking for Bitcoin wallet development company then visit https://goo.gl/uTwszR

  • Farhan

    If you need a professional help compile bitcoin source code I would suggest you service of consultant here: http://www.incubasysblockchain.com/blockchain-consultant-dubai/