First Bitcoind Compile Attempt on CentOS 6.4Woohoo! Today I found some time to prepare for an initial compile of bitcoind from
https://github.com/bitcoin/bitcoin.github.com.
1. First I wiped the existing AWS EC2 machine, re-instantiating a fresh CentOS 6.4 machine on the Amazon Cloud and logging in via ssh/putty.
[root]$ echo "Your fresh AWS EC2 machine is $(cat /proc/version*)"
Your fresh AWS EC2 machine is Linux version 2.6.32-279.el6.x86_64 ([email protected])
2. Install dependencies as far as I could figure them out
yum update
yum install 'Development tools'
yum install openssl-devel
yum install boost
yum install db4
3. Add a new user abc and pull the bitcoin source code from github
adduser abc; su abc; mkdir src; cd src
git clone git://github.com/bitcoin/bitcoin.git
cd /home/abc/src/bitcoin/src
4. Change the variable USE_UPNP in file makefile.unix so the library miniUPNP is
not included.
I apologise for using the obscure sed editor here but this way anyone can accurately duplicate the result.
sed -i -e "s/^USE_UPNP.*/USE_UPNP:=-/" makefile.unix
5. Finally, try a compile of bitcoind as per the instructions in the bitcoin/doc directory
[abc]$ cd /home/abc/src/bitcoin/src
[abc]$ make -f makefile.unix
6. The result? Well, a bunch of files compiled happily until this:
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 -I/home/abc/src/bitcoin/src -I/home/abc/src/bitcoin/src/obj -DUSE_IPV6=1 -I/home/abc/src/bitcoin/src/leveldb/include -I/home/abc/src/bitcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2 -MMD -MF obj/alert.d -o obj/alert.o alert.cpp
alert.cpp:6:53: warning: boost/algorithm/string/classification.hpp: No such file or directory
alert.cpp:7:46: warning: boost/algorithm/string/replace.hpp: No such file or directory
alert.cpp:8:29: warning: boost/foreach.hpp: No such file or directory
In file included from alert.h:13, from alert.cpp:11:
util.h:23:29: warning: boost/version.hpp: No such file or directory
util.h:24:28: warning: boost/thread.hpp: No such file or directory
util.h:25:32: warning: boost/filesystem.hpp: No such file or directory
Doh. It seems as if a bunch of boost files are not found.
7. Not going to give up that easily. Go back to root, yum-install boost-development package, try again.
[abc]$ exit # To root user
[root]# yum install boost-devel
Package boost-devel-1.41.0-17.el6_4.x86_64 installed
[root]# su abc # Become user abc again
[abc]$ cd /home/abc/src/bitcoin/src # where the makefile is
[abc]$ make -f makefile.unix
The above errors go away!
/bin/sh ../share/genbuild.sh obj/build.h
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 -I/home/abc/src/bitcoin/src -I/home/abc/src/bitcoin/src/obj -DUSE_IPV6=1 -I/home/abc/src/bitcoin/src/leveldb/include -I/home/abc/src/bitcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2 -MMD -MF obj/key.d -o obj/key.o key.cpp
key.cpp:5:27: warning: openssl/ecdsa.h: No such file or directory
key.cpp:16: error: ‘EC_KEY’ was not declared in this scope
key.cpp:55: error: ‘ECDSA_SIG’ was not declared in this scope
The new errors are kind-of expected, because I read somewhere that openssl gets compiled without EC (elliptic curves) due to some patent issue.
8. New quest would be to find an openssl with EC turned on.
In
https://bitcointalksearch.org/topic/m.991835 Jeff Garzik, bitcoin core dev team guru, says:
From: Jeff Garzik, bitcoin core dev team
Re: ECDSA dropped out of openssl 1.0.0b June 26, 2012, 05:39:39 PM
The preferred "fixes" for Red Hat, CentOS, Fedora systems are, if you want to do it yourself,
1) Download SRPM
2) Download associated source code from openssl.org
3) Edit SPECS/openssl.spec,
a) replacing source tarball filename with the downloaded one
b) comment out all references to source1
c) remove the "no-ec" stuff from the configure line
4) rebuild with "rpmbuild -ba SPECS/openssl.spec" or similar
5) install build rpms found in RPMS/
Not yet sure what all those steps would translate to on my AWS EC2 CentOS box, but will be finding out over the next few days.
8. Ok, think I have Jeff's step 1 figured out - it's downloading a .src.rpm fetch from the CentOS mother code vault
[root]# su abc # Currently root, become user abc
[abc]$ cd /home/abc # Go to abc's home directory
[abcl]$ # Use curl to download the openssl SRPM (Source RPM) package
[abc]$ curl -O http://vault.centos.org/6.4/os/Source/SPackages/openssl-1.0.0-27.el6.src.rpm
(4.11 MB/s) - “openssl-1.0.0-27.el6.src.rpm” saved [3419292/3419292]
Comments & tips welcome.
I also read this
http://wiki.centos.org/TipsAndTricks/YumAndRPM - everything is not 100% clear yet but 14.1 seems important.
14. Get set up for rebuilding packages as yourself, not root
Sometimes you just have to rebuild that package - maybe only to use some configuration option which just isn't there in the official package.
So here's how to rebuild your packages in your home directory - with your own user account.
Material to read:
http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment http://wiki.centos.org/HowTos/RebuildSRPMThanks TrevorH1
9. So, below a first attempt at taking apart a Source RPM package...
[root]# yum install rpm-build # from the instructions at http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
[root]# yum install redhat-rpm-config # from the instructions at http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
[root]# su abc # become the non-root user
[abc]$ rpm -ivh /home/abc/openssl-1.0.0-27.el6.src.rpm # from the instructions at http://bradthemad.org/tech/notes/patching_rpms.php
Holy cow, that seems like a lot of work. Former east coast racing sailor, the guitar-playing Bradthemad says on his site
Part of the philosophy behind RPM is that the build process should be repeatable, as explained here. It may be small consolation when you just want make a simple change on your own system, where building once is good enough, but that's the way it is.
Ktks, got it Bradthemad. Time to suck it up and code on. And if you're still following this post you're as hardcore as yours truly to get bitcoind going on CentOS
10. Start fiddling with the source in openssl SRPM
These steps have been deleted
11. Now have to figure out which config (or source) files to edit in order to re-enable the elliptic curve code in openssl on CentOS 6.4...
Hero Member kano on bitcointalk:
https://bitcointalksearch.org/topic/bounty-openssl-with-ec-for-fedorarhcentos-36-btc-85228 says we have to change
enable-ec enable-ecdh enable-ecdsa
Also, it seems that you have to replace the .bz2 file in the source with a .gz fresh file from
www.openssl.org, and then update the openssl.spec file to reflect that.
[abc]$ cd /home/abc/rpmbuild/SOURCES
[abc]$ mv openssl-1.0.0-usa.tar.bz2 openssl-1.0.0-usa.tar.bz2-original
[abc]$ curl -O http://www.openssl.org/source/openssl-1.0.0j.tar.gz
[abc]$ mv openssl-1.0.0j.tar.gz openssl-1.0.0-usa.tar.gz
In SOURCES/openssl.spec:
search for
Source1: hobble-openssl
(line 29) and change it (comment it out) to:
#Source1: hobble-openssl
search for
%{SOURCE1} > /dev/null
(line 133) and change it (comment it out) to:
#%{SOURCE1} > /dev/null
search fpr
Source: openssl-%{version}-usa.tar.bz2
(line nnn) and change it to
Source: openssl-%{version}j.tar.gz
Thank you kano!
12. A few more changes to the openssl.spec file and the we rebuild the package with rpmbuild.
[abc]$ sed -i -e "s/no-ec/enable_ec/; s/no-ecdh/enable-ecdh/; s/no-ecdsa/enable-ecdsa/" /home/abc/rpmbuild/SPECS/openssl.spec # Used sed editor to delete the no-ecdsa and no-ec directives from the specfile
[abc]$ cd /home/abc/rpmbuild
[abc]$ rpmbuild -ba SPECS/openssl.spec # From instructions at http://wiki.centos.org/HowTos/RebuildSRPM
The above rpmbuild of the openssl package results in an error
+ umask 022
+ cd /home/abc/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /home/abc/rpmbuild/BUILD
+ rm -rf openssl-1.0.0
+ /bin/tar -xf -
+ /usr/bin/gzip -dc /home/abc/rpmbuild/SOURCES/openssl-1.0.0j.tar.gz
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd openssl-1.0.0
/var/tmp/rpm-tmp.IOaGqm: line 38: cd: openssl-1.0.0: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.IOaGqm (%prep)
It's close, but not exactly there. From the above, when
/usr/bin/gzip -dc /home/abc/rpmbuild/SOURCES/openssl-1.0.0j.tar.gz runs, the archive gets extracted to openssl-1.0.0j instead of openssl-1.0.0. Therefore, when the
cd openssl-1.0.0 happens, a "no such directory" is thrown, because everything is in
openssl-1.0.0j.
So, seems close, but not 100% there. Comments welcomed.