1# FreeBSD Build Guide
2
3**Updated for FreeBSD [12.2](https://www.freebsd.org/releases/12.2R/announce.html)**
4
5This guide describes how to build bitcoind, command-line utilities, and GUI on FreeBSD.
6
7## Dependencies
8
9The following dependencies are **required**:
10
11 Library                                                               | Purpose    | Description
12 ----------------------------------------------------------------------|------------|----------------------
13 [autoconf](https://svnweb.freebsd.org/ports/head/devel/autoconf/)     | Build      | Automatically configure software source code
14 [automake](https://svnweb.freebsd.org/ports/head/devel/automake/)     | Build      | Generate makefile (requires autoconf)
15 [libtool](https://svnweb.freebsd.org/ports/head/devel/libtool/)       | Build      | Shared library support
16 [pkgconf](https://svnweb.freebsd.org/ports/head/devel/pkgconf/)       | Build      | Configure compiler and linker flags
17 [git](https://svnweb.freebsd.org/ports/head/devel/git/)               | Clone      | Version control system
18 [gmake](https://svnweb.freebsd.org/ports/head/devel/gmake/)           | Compile    | Generate executables
19 [boost-libs](https://svnweb.freebsd.org/ports/head/devel/boost-libs/) | Utility    | Library for threading, data structures, etc
20 [libevent](https://svnweb.freebsd.org/ports/head/devel/libevent/)     | Networking | OS independent asynchronous networking
21
22
23The following dependencies are **optional**:
24
25  Library                                                                    | Purpose          | Description
26  ---------------------------------------------------------------------------|------------------|----------------------
27  [db5](https://svnweb.freebsd.org/ports/head/databases/db5/)                | Berkeley DB      | Wallet storage (only needed when wallet enabled)
28  [qt5](https://svnweb.freebsd.org/ports/head/devel/qt5/)                    | GUI              | GUI toolkit (only needed when GUI enabled)
29  [libqrencode](https://svnweb.freebsd.org/ports/head/graphics/libqrencode/) | QR codes in GUI  | Generating QR codes (only needed when GUI enabled)
30  [libzmq4](https://svnweb.freebsd.org/ports/head/net/libzmq4/)              | ZMQ notification | Allows generating ZMQ notifications (requires ZMQ version >= 4.0.0)
31  [sqlite3](https://svnweb.freebsd.org/ports/head/databases/sqlite3/)        | SQLite DB        | Wallet storage (only needed when wallet enabled)
32  [python3](https://svnweb.freebsd.org/ports/head/lang/python3/)             | Testing          | Python Interpreter (only needed when running the test suite)
33
34  See [dependencies.md](dependencies.md) for a complete overview.
35
36## Preparation
37
38### 1. Install Required Dependencies
39Install the required dependencies the usual way you [install software on FreeBSD](https://www.freebsd.org/doc/en/books/handbook/ports.html) - either with `pkg` or via the Ports collection. The example commands below use `pkg` which is usually run as `root` or via `sudo`. If you want to use `sudo`, and you haven't set it up: [use this guide](http://www.freebsdwiki.net/index.php/Sudo%2C_configuring) to setup `sudo` access on FreeBSD.
40
41```bash
42pkg install autoconf automake boost-libs git gmake libevent libtool pkgconf
43
44```
45
46### 2. Clone Bitcoin Repo
47Now that `git` and all the required dependencies are installed, let's clone the Bitcoin Core repository to a directory. All build scripts and commands will run from this directory.
48``` bash
49git clone https://github.com/bitcoin/bitcoin.git
50```
51
52### 3. Install Optional Dependencies
53
54#### Wallet Dependencies
55It is not necessary to build wallet functionality to run bitcoind or the GUI. To enable legacy wallets, you must install `db5`. To enable [descriptor wallets](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md), `sqlite3` is required. Skip `db5` if you intend to *exclusively* use descriptor wallets
56
57###### Legacy Wallet Support
58`db5` is required to enable support for legacy wallets. Skip if you don't intend to use legacy wallets
59
60```bash
61pkg install db5
62```
63
64###### Descriptor Wallet Support
65
66`sqlite3` is required to enable support for descriptor wallets. Skip if you don't intend to use descriptor wallets.
67``` bash
68pkg install sqlite3
69```
70---
71
72#### GUI Dependencies
73###### Qt5
74
75Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install `qt5`. Skip if you don't intend to use the GUI.
76```bash
77pkg install qt5
78```
79###### libqrencode
80
81The GUI can encode addresses in a QR Code. To build in QR support for the GUI, install `libqrencode`. Skip if not using the GUI or don't want QR code functionality.
82```bash
83pkg install libqrencode
84```
85---
86
87#### Test Suite Dependencies
88There is an included test suite that is useful for testing code changes when developing.
89To run the test suite (recommended), you will need to have Python 3 installed:
90
91```bash
92pkg install python3
93```
94---
95
96## Building Bitcoin Core
97
98### 1. Configuration
99
100There are many ways to configure Bitcoin Core, here are a few common examples:
101##### Wallet (BDB + SQlite) Support, No GUI:
102This explicitly enables legacy wallet support and disables the GUI. If `sqlite3` is installed, then descriptor wallet support will be built.
103```bash
104./autogen.sh
105./configure --with-gui=no --with-incompatible-bdb \
106    BDB_LIBS="-ldb_cxx-5" \
107    BDB_CFLAGS="-I/usr/local/include/db5" \
108    MAKE=gmake
109```
110
111##### Wallet (only SQlite) and GUI Support:
112This explicitly enables the GUI and disables legacy wallet support. If `qt5` is not installed, this will throw an error. If `sqlite3` is installed then descriptor wallet functionality will be built. If `sqlite3` is not installed, then wallet functionality will be disabled.
113```bash
114./autogen.sh
115./configure --without-bdb --with-gui=yes MAKE=gmake
116```
117##### No Wallet or GUI
118``` bash
119./autogen.sh
120./configure --without-wallet --with-gui=no MAKE=gmake
121```
122
123### 2. Compile
124**Important**: Use `gmake` (the non-GNU `make` will exit with an error).
125
126```bash
127gmake # use "-j N" for N parallel jobs
128gmake check # Run tests if Python 3 is available
129```
130