|
1 |
| -OpenBSD build guide |
2 |
| -====================== |
3 |
| -(updated for OpenBSD 6.9) |
| 1 | +# OpenBSD Build Guide |
4 | 2 |
|
5 |
| -This guide describes how to build bitcoind, bitcoin-qt, and command-line utilities on OpenBSD. |
| 3 | +**Updated for OpenBSD [7.0](https://www.openbsd.org/70.html)** |
6 | 4 |
|
7 |
| -Preparation |
8 |
| -------------- |
| 5 | +This guide describes how to build bitcoind, command-line utilities, and GUI on OpenBSD. |
9 | 6 |
|
10 |
| -Run the following as root to install the base dependencies for building: |
| 7 | +## Preparation |
| 8 | + |
| 9 | +### 1. Install Required Dependencies |
| 10 | +Run the following as root to install the base dependencies for building. |
11 | 11 |
|
12 | 12 | ```bash
|
13 |
| -pkg_add git gmake libevent libtool boost |
14 |
| -pkg_add qt5 # (optional for enabling the GUI) |
15 |
| -pkg_add autoconf # (select highest version, e.g. 2.69) |
16 |
| -pkg_add automake # (select highest version, e.g. 1.16) |
17 |
| -pkg_add python # (select highest version, e.g. 3.8) |
18 |
| -pkg_add bash |
| 13 | +pkg_add bash git gmake libevent libtool boost |
| 14 | +# Select the newest version of the follow packages: |
| 15 | +pkg_add autoconf automake python |
| 16 | +``` |
19 | 17 |
|
| 18 | +See [dependencies.md](dependencies.md) for a complete overview. |
| 19 | + |
| 20 | +### 2. Clone Bitcoin Repo |
| 21 | +Clone the Bitcoin Core repository to a directory. All build scripts and commands will run from this directory. |
| 22 | +``` bash |
20 | 23 | git clone https://github.com/bitcoin/bitcoin.git
|
21 | 24 | ```
|
22 | 25 |
|
23 |
| -See [dependencies.md](dependencies.md) for a complete overview. |
| 26 | +### 3. Install Optional Dependencies |
24 | 27 |
|
25 |
| -**Important**: From OpenBSD 6.2 onwards a C++11-supporting clang compiler is |
26 |
| -part of the base image, and while building it is necessary to make sure that |
27 |
| -this compiler is used and not ancient g++ 4.2.1. This is done by appending |
28 |
| -`CC=cc CXX=c++` to configuration commands. Mixing different compilers within |
29 |
| -the same executable will result in errors. |
| 28 | +#### Wallet Dependencies |
30 | 29 |
|
31 |
| -### Building BerkeleyDB |
| 30 | +It is not necessary to build wallet functionality to run either `bitcoind` or `bitcoin-qt`. |
| 31 | + |
| 32 | +###### Descriptor Wallet Support |
| 33 | + |
| 34 | +`sqlite3` is required to support [descriptor wallets](descriptors.md). |
| 35 | + |
| 36 | +``` bash |
| 37 | +pkg_add install sqlite3 |
| 38 | +``` |
32 | 39 |
|
33 |
| -BerkeleyDB is only necessary for the wallet functionality. To skip this, pass |
34 |
| -`--disable-wallet` to `./configure` and skip to the next section. |
| 40 | +###### Legacy Wallet Support |
| 41 | +BerkeleyDB is only required to support legacy wallets. |
35 | 42 |
|
36 | 43 | It is recommended to use Berkeley DB 4.8. You cannot use the BerkeleyDB library
|
37 |
| -from ports, for the same reason as boost above (g++/libstd++ incompatibility). |
38 |
| -If you have to build it yourself, you can use [the installation script included |
39 |
| -in contrib/](/contrib/install_db4.sh) like so: |
| 44 | +from ports. However you can build it yourself, [using the installation script included in contrib/](/contrib/install_db4.sh), like so, from the root of the repository. |
40 | 45 |
|
41 | 46 | ```bash
|
42 |
| -./contrib/install_db4.sh `pwd` CC=cc CXX=c++ |
| 47 | +./contrib/install_db4.sh `pwd` |
43 | 48 | ```
|
44 | 49 |
|
45 |
| -from the root of the repository. Then set `BDB_PREFIX` for the next section: |
| 50 | +Then set `BDB_PREFIX`: |
46 | 51 |
|
47 | 52 | ```bash
|
48 | 53 | export BDB_PREFIX="$PWD/db4"
|
49 | 54 | ```
|
50 | 55 |
|
51 |
| -### Building Bitcoin Core |
| 56 | +#### GUI Dependencies |
| 57 | +###### Qt5 |
| 58 | + |
| 59 | +Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, Qt 5 is required. |
| 60 | + |
| 61 | +```bash |
| 62 | +pkg_add qt5 |
| 63 | +``` |
| 64 | + |
| 65 | +## Building Bitcoin Core |
52 | 66 |
|
53 | 67 | **Important**: Use `gmake` (the non-GNU `make` will exit with an error).
|
54 | 68 |
|
55 | 69 | Preparation:
|
56 | 70 | ```bash
|
57 | 71 |
|
58 |
| -# Replace this with the autoconf version that you installed. Include only |
59 |
| -# the major and minor parts of the version: use "2.69" for "autoconf-2.69p2". |
60 |
| -export AUTOCONF_VERSION=2.69 |
61 |
| - |
62 |
| -# Replace this with the automake version that you installed. Include only |
63 |
| -# the major and minor parts of the version: use "1.16" for "automake-1.16.1". |
| 72 | +# Adapt the following for the version you installed (major.minor only): |
| 73 | +export AUTOCONF_VERSION=2.71 |
64 | 74 | export AUTOMAKE_VERSION=1.16
|
65 | 75 |
|
66 | 76 | ./autogen.sh
|
67 | 77 | ```
|
68 |
| -Make sure `BDB_PREFIX` is set to the appropriate path from the above steps. |
| 78 | + |
| 79 | +### 1. Configuration |
69 | 80 |
|
70 | 81 | Note that building with external signer support currently fails on OpenBSD,
|
71 | 82 | hence you have to explicitly disable it by passing the parameter
|
72 |
| -`--disable-external-signer` to the configure script. |
73 |
| -(Background: the feature requires the header-only library boost::process, which |
74 |
| -is available on OpenBSD 6.9 via Boost 1.72.0, but contains certain system calls |
75 |
| -and preprocessor defines like `waitid()` and `WEXITED` that are not available.) |
| 83 | +`--disable-external-signer` to the configure script. The feature requires the |
| 84 | +header-only library boost::process, which is available on OpenBSD, but contains |
| 85 | +certain system calls and preprocessor defines like `waitid()` and `WEXITED` that |
| 86 | +are not available. |
76 | 87 |
|
77 |
| -To configure with wallet: |
78 |
| -```bash |
79 |
| -./configure --with-gui=no --disable-external-signer CC=cc CXX=c++ \ |
80 |
| - BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" \ |
81 |
| - BDB_CFLAGS="-I${BDB_PREFIX}/include" \ |
82 |
| - MAKE=gmake |
83 |
| -``` |
| 88 | +There are many ways to configure Bitcoin Core, here are a few common examples: |
| 89 | + |
| 90 | +##### Descriptor Wallet and GUI: |
| 91 | +This enables the GUI and descriptor wallet support, assuming `sqlite` and `qt5` are installed. |
84 | 92 |
|
85 |
| -To configure without wallet: |
86 | 93 | ```bash
|
87 |
| -./configure --disable-wallet --with-gui=no --disable-external-signer CC=cc CXX=c++ MAKE=gmake |
| 94 | +./configure --disable-external-signer MAKE=gmake |
88 | 95 | ```
|
89 | 96 |
|
90 |
| -To configure with GUI: |
| 97 | +##### Descriptor & Legacy Wallet. No GUI: |
| 98 | +This enables support for both wallet types and disables the GUI: |
| 99 | + |
91 | 100 | ```bash
|
92 |
| -./configure --with-gui=yes --disable-external-signer CC=cc CXX=c++ \ |
| 101 | +./configure --disable-external-signer --with-gui=no \ |
93 | 102 | BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" \
|
94 | 103 | BDB_CFLAGS="-I${BDB_PREFIX}/include" \
|
95 | 104 | MAKE=gmake
|
96 | 105 | ```
|
97 | 106 |
|
98 |
| -Build and run the tests: |
| 107 | +### 2. Compile |
| 108 | +**Important**: Use `gmake` (the non-GNU `make` will exit with an error). |
| 109 | + |
99 | 110 | ```bash
|
100 |
| -gmake # use "-j N" here for N parallel jobs |
101 |
| -gmake check |
| 111 | +gmake # use "-j N" for N parallel jobs |
| 112 | +gmake check # Run tests if Python 3 is available |
102 | 113 | ```
|
103 | 114 |
|
104 |
| -Resource limits |
105 |
| -------------------- |
| 115 | +## Resource limits |
106 | 116 |
|
107 | 117 | If the build runs into out-of-memory errors, the instructions in this section
|
108 | 118 | might help.
|
109 | 119 |
|
110 | 120 | The standard ulimit restrictions in OpenBSD are very strict:
|
111 |
| - |
112 |
| - data(kbytes) 1572864 |
| 121 | +```bash |
| 122 | +data(kbytes) 1572864 |
| 123 | +``` |
113 | 124 |
|
114 | 125 | This is, unfortunately, in some cases not enough to compile some `.cpp` files in the project,
|
115 | 126 | (see issue [#6658](https://github.com/bitcoin/bitcoin/issues/6658)).
|
116 | 127 | If your user is in the `staff` group the limit can be raised with:
|
117 |
| - |
118 |
| - ulimit -d 3000000 |
119 |
| - |
| 128 | +```bash |
| 129 | +ulimit -d 3000000 |
| 130 | +``` |
120 | 131 | The change will only affect the current shell and processes spawned by it. To
|
121 | 132 | make the change system-wide, change `datasize-cur` and `datasize-max` in
|
122 | 133 | `/etc/login.conf`, and reboot.
|
123 |
| - |
|
0 commit comments