Merge #11552: Improve wallet-accounts test
[bitcoinplatinum.git] / doc / build-openbsd.md
blob760bb69b158a366bd0d0240271a6eda8446f02cd
1 OpenBSD build guide
2 ======================
3 (updated for OpenBSD 6.2)
5 This guide describes how to build bitcoind and command-line utilities on OpenBSD.
7 OpenBSD is most commonly used as a server OS, so this guide does not contain instructions for building the GUI.
9 Preparation
10 -------------
12 Run the following as root to install the base dependencies for building:
14 ```bash
15 pkg_add git gmake libevent libtool
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.6)
19 pkg_add boost
21 git clone https://github.com/bitcoin/bitcoin.git
22 ```
24 See [dependencies.md](dependencies.md) for a complete overview.
26 GCC
27 -------
29 The default C++ compiler that comes with OpenBSD 6.2 is g++ 4.2.1. This version is old (from 2007), and is not able to compile the current version of Bitcoin Core because it has no C++11 support. We'll install a newer version of GCC:
31 ```bash
32  pkg_add g++
33  ```
35  This compiler will not overwrite the system compiler, it will be installed as `egcc` and `eg++` in `/usr/local/bin`.
37 ### Building BerkeleyDB
39 BerkeleyDB is only necessary for the wallet functionality. To skip this, pass `--disable-wallet` to `./configure`.
41 See "Berkeley DB" in [build-unix.md](build-unix.md#berkeley-db) for instructions on how to build BerkeleyDB 4.8.
42 You cannot use the BerkeleyDB library from ports, for the same reason as boost above (g++/libstd++ incompatibility).
44 ```bash
45 # Pick some path to install BDB to, here we create a directory within the bitcoin directory
46 BITCOIN_ROOT=$(pwd)
47 BDB_PREFIX="${BITCOIN_ROOT}/db4"
48 mkdir -p $BDB_PREFIX
50 # Fetch the source and verify that it is not tampered with
51 curl -o db-4.8.30.NC.tar.gz 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
52 echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef  db-4.8.30.NC.tar.gz' | sha256 -c
53 # MUST output: (SHA256) db-4.8.30.NC.tar.gz: OK
54 tar -xzf db-4.8.30.NC.tar.gz
56 # Build the library and install to specified prefix
57 cd db-4.8.30.NC/build_unix/
58 #  Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime
59 ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX CC=egcc CXX=eg++ CPP=ecpp
60 make install # do NOT use -jX, this is broken
61 ```
63 ### Resource limits
65 The standard ulimit restrictions in OpenBSD are very strict:
67     data(kbytes)         1572864
69 This, unfortunately, may no longer be enough to compile some `.cpp` files in the project,
70 at least with GCC 4.9.4 (see issue [#6658](https://github.com/bitcoin/bitcoin/issues/6658)).
71 If your user is in the `staff` group the limit can be raised with:
73     ulimit -d 3000000
75 The change will only affect the current shell and processes spawned by it. To
76 make the change system-wide, change `datasize-cur` and `datasize-max` in
77 `/etc/login.conf`, and reboot.
79 ### Building Bitcoin Core
81 **Important**: use `gmake`, not `make`. The non-GNU `make` will exit with a horrible error.
83 Preparation:
84 ```bash
85 export AUTOCONF_VERSION=2.69 # replace this with the autoconf version that you installed
86 export AUTOMAKE_VERSION=1.15 # replace this with the automake version that you installed
87 ./autogen.sh
88 ```
89 Make sure `BDB_PREFIX` is set to the appropriate path from the above steps.
91 To configure with wallet:
92 ```bash
93 ./configure --with-gui=no CC=egcc CXX=eg++ CPP=ecpp \
94     BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include"
95 ```
97 To configure without wallet:
98 ```bash
99 ./configure --disable-wallet --with-gui=no CC=egcc CXX=eg++ CPP=ecpp
102 Build and run the tests:
103 ```bash
104 gmake # use -jX here for parallelism
105 gmake check
108 Clang
109 ------------------------------
111 ```bash
112 pkg_add llvm
114 ./configure --disable-wallet --with-gui=no CC=clang CXX=clang++
115 gmake # use -jX here for parallelism
116 gmake check