3 (updated for OpenBSD 5.9)
5 This guide describes how to build bitcoind and command-line utilities on OpenBSD.
7 As OpenBSD is most common as a server OS, we will not bother with the GUI.
12 Run the following as root to install the base dependencies for building:
15 pkg_add gmake libtool libevent
16 pkg_add autoconf # (select highest version, e.g. 2.69)
17 pkg_add automake # (select highest version, e.g. 1.15)
18 pkg_add python # (select highest version, e.g. 3.5)
21 The default C++ compiler that comes with OpenBSD 5.9 is g++ 4.2. This version is old (from 2007), and is not able to compile the current version of Bitcoin Core, primarily as it has no C++11 support, but even before there were issues. So here we will be installing a newer compiler.
26 You can install a newer version of gcc with:
29 pkg_add g++ # (select newest 4.x version, e.g. 4.9.3)
32 This compiler will not overwrite the system compiler, it will be installed as `egcc` and `eg++` in `/usr/local/bin`.
36 Do not use `pkg_add boost`! The boost version installed thus is compiled using the `g++` compiler not `eg++`, which will result in a conflict between `/usr/local/lib/libestdc++.so.XX.0` and `/usr/lib/libstdc++.so.XX.0`, resulting in a test crash:
38 test_bitcoin:/usr/lib/libstdc++.so.57.0: /usr/local/lib/libestdc++.so.17.0 : WARNING: symbol(_ZN11__gnu_debug17_S_debug_me ssagesE) size mismatch, relink your program
40 Segmentation fault (core dumped)
42 This makes it necessary to build boost, or at least the parts used by Bitcoin Core, manually:
45 # Pick some path to install boost to, here we create a directory within the bitcoin directory
47 BOOST_PREFIX="${BITCOIN_ROOT}/boost"
48 mkdir -p $BOOST_PREFIX
50 # Fetch the source and verify that it is not tampered with
51 curl -o boost_1_61_0.tar.bz2 http://heanet.dl.sourceforge.net/project/boost/boost/1.61.0/boost_1_61_0.tar.bz2
52 echo 'a547bd06c2fd9a71ba1d169d9cf0339da7ebf4753849a8f7d6fdb8feee99b640 boost_1_61_0.tar.bz2' | sha256 -c
53 # MUST output: (SHA256) boost_1_61_0.tar.bz2: OK
54 tar -xjf boost_1_61_0.tar.bz2
56 # Boost 1.61 needs one small patch for OpenBSD
58 # Also here: https://gist.githubusercontent.com/laanwj/bf359281dc319b8ff2e1/raw/92250de8404b97bb99d72ab898f4a8cb35ae1ea3/patch-boost_test_impl_execution_monitor_ipp.patch
59 patch -p0 < /usr/ports/devel/boost/patches/patch-boost_test_impl_execution_monitor_ipp
61 # Build w/ minimum configuration necessary for bitcoin
62 echo 'using gcc : : eg++ : <cxxflags>"-fvisibility=hidden -fPIC" <linkflags>"" <archiver>"ar" <striper>"strip" <ranlib>"ranlib" <rc>"" : ;' > user-config.jam
63 config_opts="runtime-link=shared threadapi=pthread threading=multi link=static variant=release --layout=tagged --build-type=complete --user-config=user-config.jam -sNO_BZIP2=1"
64 ./bootstrap.sh --without-icu --with-libraries=chrono,filesystem,program_options,system,thread,test
65 ./b2 -d2 -j2 -d1 ${config_opts} --prefix=${BOOST_PREFIX} stage
66 ./b2 -d0 -j4 ${config_opts} --prefix=${BOOST_PREFIX} install
69 ### Building BerkeleyDB
71 BerkeleyDB is only necessary for the wallet functionality. To skip this, pass `--disable-wallet` to `./configure`.
73 See "Berkeley DB" in [build_unix.md](build_unix.md) for instructions on how to build BerkeleyDB 4.8.
74 You cannot use the BerkeleyDB library from ports, for the same reason as boost above (g++/libstd++ incompatibility).
77 # Pick some path to install BDB to, here we create a directory within the bitcoin directory
79 BDB_PREFIX="${BITCOIN_ROOT}/db4"
82 # Fetch the source and verify that it is not tampered with
83 curl -o db-4.8.30.NC.tar.gz 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
84 echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz' | sha256 -c
85 # MUST output: (SHA256) db-4.8.30.NC.tar.gz: OK
86 tar -xzf db-4.8.30.NC.tar.gz
88 # Build the library and install to specified prefix
89 cd db-4.8.30.NC/build_unix/
90 # Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime
91 ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX CC=egcc CXX=eg++ CPP=ecpp
92 make install # do NOT use -jX, this is broken
97 The standard ulimit restrictions in OpenBSD are very strict:
101 This is, unfortunately, no longer enough to compile some `.cpp` files in the project,
102 at least with gcc 4.9.3 (see issue https://github.com/bitcoin/bitcoin/issues/6658).
103 If your user is in the `staff` group the limit can be raised with:
107 The change will only affect the current shell and processes spawned by it. To
108 make the change system-wide, change `datasize-cur` and `datasize-max` in
109 `/etc/login.conf`, and reboot.
111 ### Building Bitcoin Core
113 **Important**: use `gmake`, not `make`. The non-GNU `make` will exit with a horrible error.
117 export AUTOCONF_VERSION=2.69 # replace this with the autoconf version that you installed
118 export AUTOMAKE_VERSION=1.15 # replace this with the automake version that you installed
121 Make sure `BDB_PREFIX` and `BOOST_PREFIX` are set to the appropriate paths from the above steps.
123 To configure with wallet:
125 ./configure --with-gui=no --with-boost=$BOOST_PREFIX \
126 CC=egcc CXX=eg++ CPP=ecpp \
127 LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/"
130 To configure without wallet:
132 ./configure --disable-wallet --with-gui=no --with-boost=$BOOST_PREFIX \
133 CC=egcc CXX=eg++ CPP=ecpp
136 Build and run the tests:
138 gmake # can use -jX here for parallelism
142 Clang (not currently working)
143 ------------------------------
145 Using a newer g++ results in linking the new code to a new libstdc++.
146 Libraries built with the old g++, will still import the old library.
147 This gives conflicts, necessitating rebuild of all C++ dependencies of the application.
149 With clang this can - at least theoretically - be avoided because it uses the
150 base system's libstdc++.
157 ./configure --disable-wallet --with-gui=no CC=clang CXX=clang++
161 However, this does not appear to work. Compilation succeeds, but link fails
162 with many 'local symbol discarded' errors:
164 local symbol 150: discarded in section `.text._ZN10tinyformat6detail14FormatIterator6finishEv' from libbitcoin_util.a(libbitcoin_util_a-random.o)
165 local symbol 151: discarded in section `.text._ZN10tinyformat6detail14FormatIterator21streamStateFromFormatERSoRjPKcii' from libbitcoin_util.a(libbitcoin_util_a-random.o)
166 local symbol 152: discarded in section `.text._ZN10tinyformat6detail12convertToIntIA13_cLb0EE6invokeERA13_Kc' from libbitcoin_util.a(libbitcoin_util_a-random.o)
168 According to similar reported errors this is a binutils (ld) issue in 2.15, the
169 version installed by OpenBSD 5.7:
171 - http://openbsd-archive.7691.n7.nabble.com/UPDATE-cppcheck-1-65-td248900.html
172 - https://llvm.org/bugs/show_bug.cgi?id=9758
174 There is no known workaround for this.