Pages:
Author

Topic: [Paid] [Bounty: 10 BTC] Bitcoind build instructions for Centos x86 and x64 - page 3. (Read 15613 times)

kjj
legendary
Activity: 1302
Merit: 1026
Ok, I may be hung over, but the script is working.

I wanted to just paste it into the forums, but when I do, it messes up the tabs and spaces.  Instead, you'll need to download them.

Build Script
Makefile

Download these two files into a normal user's home directory ( /home/whatever ), set the script executable, then run it.  The script will fetch the packages, build them, then build bitcoind.
sr. member
Activity: 467
Merit: 250

This is just the Steurer guide copied over to a forum. Changing the version is not enough. Let me know if you actually build v0.6 from this and I'll give it a shot.

Well, I went more than half way through and got bored because of the time it took to compile on my VPS,

I went till the Berkeley DB Part, works perfectly till there.
legendary
Activity: 1102
Merit: 1014

This is just the Steurer guide copied over to a forum. Changing the version is not enough. Let me know if you actually build v0.6 from this and I'll give it a shot.
sr. member
Activity: 467
Merit: 250
This should work : http://www.bitcoinforums.net/threads/installing-bitcoind-on-centos-5.146/

From the tutorial :
You may have to replace :
Code:
# cd bitcoin-0.3.23/src

to
Code:
# cd bitcoin-BITCOIN VERSION HERE/src

Replacing BITCOIN VERSION HERE with the version number of bitcoind which gets downloaded from the GIT repo.
I can see the GIT repo was updated 3 days ago which means that you'll get the new version of bitcoind 6 possibly

*If* it does work, send some BTC over to 1HR26mWBjiraHEz1qVPQP5g3LiSjcRpZNy    Tongue
kjj
legendary
Activity: 1302
Merit: 1026
Ok, I can verify that this process works as I now have bitcoind running on CentOS 32-bit! \o/

kjj, would you care to explain any drawbacks to using this procedure? Is the resulting bitcoind lacking anything or is it possible that this build process is likely to introduce problems when used to build later versions of bitcoind?

Heh.  I have no idea, to be honest.  I know it doesn't include UPNP, but that shouldn't be a problem for most people running CentOS.

When I was tweaking the makefile, I kept getting strange warnings about static builds trying to dlopen shared libraries.  I think that will be a problem if someone compiles it on one box, then moves it to a box with different libraries.  I'm not really sure which libraries, if any, would cause those problems.  It could possibly also cause problems if someone updates the libraries on the box it is on.

Also, I saw that someone else had asked for a single document showing all of the steps.  I'm not much of a document sort of guy, but this might be of interest to someone.  Save it as a shell script in your user's home directory, alongside the makefile.new from above.  Then set it executable, and run it.  You should end up with a working bitcoind.  Note that I haven't tested this yet.  I'm running it right now, and so far so good, but boost takes forever to build, so it might not finish before I leave for the bar.  I'll let everyone know how it goes when I can, but that might be tomorrow.

Ignore this script.  It doesn't work, and I don't have time to fix it right now.  Check back tomorrow.

Code:
#!/bin/bash

if [ ! -x /usr/bin/wget ] ; then
 echo "for some silly reason, wget is not executable.  Please fix this (as root do chmod +x /usr/bin/wget) and try again"
 exit
fi

USERNAME=`whoami`
cd ~
mkdir Bitcoin
cd Bitcoin
mkdir Libraries
mkdir Trunk
mkdir Deps
cd Libraries

wget -qO- http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.bz2/download | tar xjv
cd boost_1_49_0
./bootstrap.sh
./bjam --prefix=~$USERNAME/Bitcoin/Deps link=static runtime-link=static install
cd ..

wget -qO- http://openssl.org/source/openssl-1.0.0g.tar.gz | tar xzv
cd openssl-1.0.0g
if uname -a | grep -q x86_64 ; then
 ./Configure no-shared --prefix=~$USERNAME/Bitcoin/Deps --openssldir=~$USERNAME/Bitcoin/Deps/openssl linux-x86_64
else
 ./Configure no-shared --prefix=~$USERNAME/Bitcoin/Deps --openssldir=~$USERNAME/Bitcoin/Deps/openssl linux-generic32
fi
make
make install
cd ..

wget -qO- http://download.oracle.com/berkeley-db/db-5.1.19.tar.gz | tar xzv
cd db-5.1.19/build_unix
../dist/configure --prefix=~$USERNAME/Deps/ --enable-cxx
make
make install
cd ../..

mkdir bitcoin-master
cd bitcoin-master
wget -qO- https://github.com/bitcoin/bitcoin/tarball/master --no-check-certificate | tar xzv --strip-components 1
cd src
#cp -vap ~$USERNAME/makefile.new .
cat ~$USERNAME/makefile.new | sed s/kjj/$USERNAME/g > makefile.new
make -f makefile.new bitcoind
legendary
Activity: 1102
Merit: 1014
Ok, I can verify that this process works as I now have bitcoind running on CentOS 32-bit! \o/

kjj, would you care to explain any drawbacks to using this procedure? Is the resulting bitcoind lacking anything or is it possible that this build process is likely to introduce problems when used to build later versions of bitcoind?
kjj
legendary
Activity: 1302
Merit: 1026
kjj, can you post your modified makefile? patch fails for me and I'm not sure if it's whitespace or what...

I found with openssl that it doesn't like relative paths so it's probably best to make these build instructions use only absolute paths throughout.

In regards to the bounty and the hackiness of this approach, who will bless it?  If it works and is presented in a single document, I would be inclined to call it done.

makefile.new below.  The make command was make -f makefile.new bitcoind

Code:
# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php.

USE_UPNP:=

DEFS=-DNOPCH

DEFS += $(addprefix -I,$(CURDIR) $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))

DEPSDIR=/home/kjj/Bitcoin/Deps
INCLUDEPATHS= -I"$(DEPSDIR)/include"
LIBPATHS= -L"$(DEPSDIR)/lib"
BOOST_LIB_SUFFIX=.a
BDB_LIB_SUFFIX=.a
CRYPTO_LIB_SUFFIX=.a

LMODE2 = static
LMODE = static

# for boost 1.37, add -mt to the boost libraries
LIBS += \
 -Wl,-Bstatic \
   -mtl $(DEPSDIR)/lib/libboost_system$(BOOST_LIB_SUFFIX) \
   -mtl $(DEPSDIR)/lib/libboost_filesystem$(BOOST_LIB_SUFFIX) \
   -mtl $(DEPSDIR)/lib/libboost_program_options$(BOOST_LIB_SUFFIX) \
   -mtl $(DEPSDIR)/lib/libboost_thread$(BOOST_LIB_SUFFIX) \
   $(DEPSDIR)/lib/libdb_cxx$(BDB_LIB_SUFFIX) \
   -mtl $(DEPSDIR)/lib/libssl.a \
   -mtl $(DEPSDIR)/lib/libcrypto$(CRYPTO_LIB_SUFFIX) \
   -lgcc

ifndef USE_UPNP
        override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
        LIBS += -l miniupnpc
        DEFS += -DUSE_UPNP=$(USE_UPNP)
endif

ifneq (${USE_SSL}, 0)
        DEFS += -DUSE_SSL
endif

LIBS+= \
 -Wl,-B$(LMODE2) \
   -l z \
   -l dl \
   -l pthread


# Hardening
# Make some classes of vulnerabilities unexploitable in case one is discovered.
#
    # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
    # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
    # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
    HARDENING=-fno-stack-protector

    # Stack Canaries
    # Put numbers at the beginning of each stack frame and check that they are the same.
    # If a stack buffer if overflowed, it writes over the canary number and then on return
    # when that number is checked, it won't be the same and the program will exit with
    # a "Stack smashing detected" error instead of being exploited.
    HARDENING+=-fstack-protector-all -Wstack-protector

    # Make some important things such as the global offset table read only as soon as
    # the dynamic linker is finished building it. This will prevent overwriting of addresses
    # which would later be jumped to.
    HARDENING+=-Wl,-z,relro -Wl,-z,now

    # Build position independent code to take advantage of Address Space Layout Randomization
    # offered by some kernels.
    # see doc/build-unix.txt for more information.
    ifdef PIE
        HARDENING+=-fPIE -pie
    endif

    # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
    # the source such overflowing a statically defined buffer.
    HARDENING+=-D_FORTIFY_SOURCE=2
#


DEBUGFLAGS=-g
CXXFLAGS=-O2
xCXXFLAGS=-pthread -Wextra -Wno-sign-compare -Wno-char-subscripts -Wno-invalid-offsetof -Wformat-security \
    $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS) $(INCLUDEPATHS) -static

OBJS= \
    obj/checkpoints.o \
    obj/netbase.o \
    obj/crypter.o \
    obj/key.o \
    obj/db.o \
    obj/init.o \
    obj/irc.o \
    obj/keystore.o \
    obj/main.o \
    obj/net.o \
    obj/protocol.o \
    obj/bitcoinrpc.o \
    obj/rpcdump.o \
    obj/script.o \
    obj/util.o \
    obj/wallet.o


all: bitcoind

# auto-generated dependencies:
-include obj/*.P
-include obj-test/*.P

obj/%.o: %.cpp
        $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
        @cp $(@:%.o=%.d) $(@:%.o=%.P); \
          sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
              -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
          rm -f $(@:%.o=%.d)

bitcoind: $(OBJS:obj/%=obj/%)
        $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)

TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))

obj-test/%.o: test/%.cpp
        $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $<
        @cp $(@:%.o=%.d) $(@:%.o=%.P); \
          sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
              -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
          rm -f $(@:%.o=%.d)

test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
        $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)

clean:
        -rm -f bitcoind test_bitcoin
        -rm -f obj/*.o
        -rm -f obj-test/*.o
        -rm -f obj/*.P
        -rm -f obj-test/*.P
legendary
Activity: 1102
Merit: 1014
kjj, can you post your modified makefile? patch fails for me and I'm not sure if it's whitespace or what...

I found with openssl that it doesn't like relative paths so it's probably best to make these build instructions use only absolute paths throughout.

In regards to the bounty and the hackiness of this approach, who will bless it?  If it works and is presented in a single document, I would be inclined to call it done.
legendary
Activity: 1102
Merit: 1014
My bad, this os isn't 64 bit after all...will report back on the rest.
kjj
legendary
Activity: 1302
Merit: 1026
Really?  I just nuked my directory to start over, and did:

Code:
tar xzvf ../../openssl-1.0.0g.tar.gz
cd openssl-1.0.0g/
./Configure no-shared --prefix=~/Bitcoin/Deps --openssldir=~/Bitcoin/Deps/openssl linux-x86_64
make depend
make

with no errors.

What was the output of your uname -a ?
legendary
Activity: 1102
Merit: 1014
Ok, I'll give kjj's a shot as soon as I can.

Update: no luck as I got the following error on 'make depend'

Code:
Configured for linux-x86_64.
[weex@centos openssl-1.0.0g]$ make depend
making depend in crypto...
make[1]: Entering directory `/home/weex/code/Bitcoin/Libraries/openssl-1.0.0g/crypto'
cryptlib.c:0: sorry, unimplemented: 64-bit mode not compiled in
mem.c:0: sorry, unimplemented: 64-bit mode not compiled in
mem_clr.c:0: sorry, unimplemented: 64-bit mode not compiled in
mem_dbg.c:0: sorry, unimplemented: 64-bit mode not compiled in
cversion.c:0: sorry, unimplemented: 64-bit mode not compiled in
ex_data.c:0: sorry, unimplemented: 64-bit mode not compiled in
cpt_err.c:0: sorry, unimplemented: 64-bit mode not compiled in
ebcdic.c:0: sorry, unimplemented: 64-bit mode not compiled in
uid.c:0: sorry, unimplemented: 64-bit mode not compiled in
o_time.c:0: sorry, unimplemented: 64-bit mode not compiled in
o_str.c:0: sorry, unimplemented: 64-bit mode not compiled in
o_dir.c:0: sorry, unimplemented: 64-bit mode not compiled in
make[1]: *** [depend] Error 1
make[1]: Leaving directory `/home/weex/code/Bitcoin/Libraries/openssl-1.0.0g/crypto'
make: *** [depend] Error 1
kjj
legendary
Activity: 1302
Merit: 1026
If you want the other links, they are:

Boost 1.49.0, or go here and pick the latest version.

openSSL-1.0.0g, or go here and pick a different release.  No idea if the betas are any good.

For BDB, go here and click the blue Download link.  Or, skip the splash pages and download 5.1.19 directly.

I didn't include them before because I figured it was easy enough for other people to copy the links out of that PDF and navigate to the current versions.

Oh, and I noticed one other thing that I did differently from the guide.  I'll edit the post to include it.

And just for fun, here is a my centos box running bitcoind, busily downloading the blockchain...

Code:
[kjj@crs00 src]$ cat /etc/redhat-release
CentOS release 5.7 (Final)
[kjj@crs00 src]$ ./bitcoind getinfo
{
    "version" : 60000,
    "protocolversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 138239,
    "connections" : 8,
    "proxy" : "",
    "difficulty" : 1690895.80305239,
    "testnet" : false,
    "keypoololdest" : 1330099058,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "errors" : ""
}
[kjj@crs00 src]$
kjj
legendary
Activity: 1302
Merit: 1026
Used version 1.49.0 of Boost
Used version 1.0.0g of openssl

How do you get boost 1.49.0 to compile?  The latest version that comes packaged for CentOS is 1.33.1

Same for openssl, the latest packaged version is 0.9.8e

The 3.22 recipe goes through great many hoops, including download links to long gone tarballs of legacy versions of those pesky libraries.  It's self-contained and requires nothing more than a CentOS install DVD, and a 3.22 git mirror.  One can follow the instructions and actually build 3.22 (for x86, and with tiny fixes also for x64).

However, requiring boost 1.49.0 without saying how to make it is not going to help.  I know because I once tried to build a recent bitcoin, and failed (after 2 days of dependency hell).

I followed the instructions in the guide that I linked exactly, with the exceptions noted.
newbie
Activity: 53
Merit: 0
Used version 1.49.0 of Boost
Used version 1.0.0g of openssl

How do you get boost 1.49.0 to compile?  The latest version that comes packaged for CentOS is 1.33.1

Same for openssl, the latest packaged version is 0.9.8e

The 3.22 recipe goes through great many hoops, including download links to long gone tarballs of legacy versions of those pesky libraries.  It's self-contained and requires nothing more than a CentOS install DVD, and a 3.22 git mirror.  One can follow the instructions and actually build 3.22 (for x86, and with tiny fixes also for x64).

However, requiring boost 1.49.0 without saying how to make it is not going to help.  I know because I once tried to build a recent bitcoin, and failed (after 2 days of dependency hell).
legendary
Activity: 1316
Merit: 1011
downloading centos now going to install in VM, I'm fairly confiant I can get this bounty  Cheesy
kjj
legendary
Activity: 1302
Merit: 1026
I just followed the instructions in the Steurer guide with the following exceptions:

Used version 1.49.0 of Boost, adjust the ./bjam line for --prefix=../../Deps
Used version 1.0.0g of openssl, add no-shared to the ./Configuration line and run make depend before make
Used the master tarball of bitcoin instead of git clone
Different makefile, using this patch fix the DEPSDIR= line to match your path:

Code:
--- makefile.unix       2012-02-23 13:33:30.000000000 -0500
+++ makefile.new        2012-02-24 10:57:14.000000000 -0500
@@ -2,34 +2,34 @@
 # Distributed under the MIT/X11 software license, see the accompanying
 # file license.txt or http://www.opensource.org/licenses/mit-license.php.

-USE_UPNP:=0
+USE_UPNP:=

 DEFS=-DNOPCH

 DEFS += $(addprefix -I,$(CURDIR) $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))

-LMODE = dynamic
-LMODE2 = dynamic
-ifdef STATIC
-       LMODE = static
-       ifeq (${STATIC}, all)
-               LMODE2 = static
-       endif
-else
-       TESTDEFS += -DBOOST_TEST_DYN_LINK
-endif
+DEPSDIR=/home/kjj/Bitcoin/Deps
+INCLUDEPATHS= -I"$(DEPSDIR)/include"
+LIBPATHS= -L"$(DEPSDIR)/lib"
+BOOST_LIB_SUFFIX=.a
+BDB_LIB_SUFFIX=.a
+CRYPTO_LIB_SUFFIX=.a
+
+LMODE2 = static
+LMODE = static

 # for boost 1.37, add -mt to the boost libraries
 LIBS += \
- -Wl,-B$(LMODE) \
-   -l boost_system$(BOOST_LIB_SUFFIX) \
-   -l boost_filesystem$(BOOST_LIB_SUFFIX) \
-   -l boost_program_options$(BOOST_LIB_SUFFIX) \
-   -l boost_thread$(BOOST_LIB_SUFFIX) \
-   -l db_cxx$(BDB_LIB_SUFFIX) \
-   -l ssl \
-   -l crypto
+ -Wl,-Bstatic \
+   -mtl $(DEPSDIR)/lib/libboost_system$(BOOST_LIB_SUFFIX) \
+   -mtl $(DEPSDIR)/lib/libboost_filesystem$(BOOST_LIB_SUFFIX) \
+   -mtl $(DEPSDIR)/lib/libboost_program_options$(BOOST_LIB_SUFFIX) \
+   -mtl $(DEPSDIR)/lib/libboost_thread$(BOOST_LIB_SUFFIX) \
+   $(DEPSDIR)/lib/libdb_cxx$(BDB_LIB_SUFFIX) \
+   -mtl $(DEPSDIR)/lib/libssl.a \
+   -mtl $(DEPSDIR)/lib/libcrypto$(CRYPTO_LIB_SUFFIX) \
+   -lgcc

 ifndef USE_UPNP
        override USE_UPNP = -
@@ -86,7 +86,7 @@
 DEBUGFLAGS=-g
 CXXFLAGS=-O2
 xCXXFLAGS=-pthread -Wextra -Wno-sign-compare -Wno-char-subscripts -Wno-invalid-offsetof -Wformat-security \
-    $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
+    $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS) $(INCLUDEPATHS) -static

 OBJS= \
     obj/checkpoints.o \


And then just make -f makefile.new bitcoind.

This is an ugly hack and I really don't know what I'm doing.  Please save the bounty until someone better gives the proper solution.
legendary
Activity: 1102
Merit: 1014
It can't really be much harder than building for any other linux OS right?

I'm sure it isn't...for someone who will with the bounty.
full member
Activity: 209
Merit: 100
It can't really be much harder than building for any other linux OS right?
legendary
Activity: 1102
Merit: 1014
Another interested party has added 2 BTC to the bounty so I've updated the topic.
legendary
Activity: 1024
Merit: 1004
I'll take a swing at it since I was able to get it to build on FreeBSD 7.1 (32-bit) and 8.2 (64-bit) Wink

The only thing crazier than that would be, I dunno, OS/2 or AmigaDOS Wink
Pages:
Jump to: