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.

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.

[pastacode lang=”bash” manual=”%23%20Update%20%26%20Upgrade%20the%20System%0Asudo%20apt-get%20update%0Asudo%20apt-get%20upgrade%0A%0A%23%20Install%20dependencies%20there%20might%20be%20more%20based%20on%20your%20system%0A%23%20However%20below%20instructions%20are%20for%20the%20fresh%20Ubuntu%20install%2Fserver%0A%23%20Please%20carefully%20watch%20the%20logs%20because%20if%20something%20could%20not%20be%20install%0A%23%20You%20have%20to%20make%20sure%20it%20is%20installed%20properly%20by%20trying%20the%20command%20or%20that%20particular%0A%23%20dependency%20again%0A%0Asudo%20apt-get%20install%20build-essential%20libtool%20autotools-dev%20autoconf%20pkg-config%20libssl-dev%0Asudo%20apt-get%20install%20libboost-all-dev%0Asudo%20apt-get%20install%20libqt5gui5%20libqt5core5a%20libqt5dbus5%20qttools5-dev%20qttools5-dev-tools%20libprotobuf-dev%20protobuf-compiler%0Asudo%20apt-get%20install%20libqrencode-dev%20autoconf%20openssl%20libssl-dev%20libevent-dev%0Asudo%20apt-get%20install%20libminiupnpc-dev%0A%0A%23%20Download%20Bitcoin%20Source%20code%0A%23%20—————————-%0Acd%20~%0Agit%20clone%20https%3A%2F%2Fgithub.com%2Fbitcoin%2Fbitcoin.git%0A%0A%23%20Bitcoin%20uses%20the%20Berkley%20DB%204.8%0A%23%20We%20need%20to%20install%20it%20as%20well%0A%23%20Download%20%26%20Install%20Berkley%20DB%0A%23%20—————————–%0Acd%20~%0Amkdir%20bitcoin%2Fdb4%2F%0Awget%20’http%3A%2F%2Fdownload.oracle.com%2Fberkeley-db%2Fdb-4.8.30.NC.tar.gz’%0Atar%20-xzvf%20db-4.8.30.NC.tar.gz%0Acd%20db-4.8.30.NC%2Fbuild_unix%2F%0A..%2Fdist%2Fconfigure%20–enable-cxx%20–disable-shared%20–with-pic%20–prefix%3D%2Fhome%2Ftheusername%2Fbitcoin%2Fdb4%2F%0Amake%20install%0A%0A%23%20Compile%20Bitcoin%20with%20Berkley%20DB%204.8%0A%23%20———————————–%0Acd%20~%2Fbitcoin%2F%0A.%2Fautogen.sh%0A%23%20below%20command%20.%2Fconfigure%20may%20return%20with%20error%20for%20dependencies%0A%23%20you%20need%20to%20make%20sure%20that%20it%20returns%20with%20no%20error%0A%23%20If%20it%20does%20please%20install%20the%20dependencies%20and%20rerun%20the%20%2Fautogen.sh%20command%20again%20and%20then%20below%20command%20again%0A.%2Fconfigure%20LDFLAGS%3D%22-L%2Fhome%2Ftheusername%2Fbitcoin%2Fdb4%2Flib%2F%22%20CPPFLAGS%3D%22-I%2Fhome%2Ftheusername%2Fbitcoin%2Fdb4%2Finclude%2F%22%0A%0A%23%20below%20command%20may%20take%205-10%20minutes%20based%20on%20your%20system%0Amake%20-s%20-j5%0A%0A%23%20If%20all%20went%20well%20you%20will%20be%20able%20to%20access%20the%20binary%20at%20below%20location%0Acd%20~%2Fbitcoin%2F%0A.%2Fsrc%2Fbitcoind%0A.%2Fsrc%2Fbitcoin-qt%0A.%2Fsrc%2Fbitcoin-cli” message=”” highlight=”” provider=”manual”/]

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