/ doc / build-unix.md
build-unix.md
  1  UNIX BUILD NOTES
  2  ====================
  3  Some notes on how to build Bitcoin Core in Unix.
  4  
  5  (For BSD specific instructions, see `build-*bsd.md` in this directory.)
  6  
  7  To Build
  8  ---------------------
  9  
 10  ```bash
 11  cmake -B build
 12  ```
 13  Run `cmake -B build -LH` to see the full list of available options.
 14  
 15  ```bash
 16  cmake --build build    # Append "-j N" for N parallel jobs
 17  cmake --install build  # Optional
 18  ```
 19  
 20  See below for instructions on how to [install the dependencies on popular Linux
 21  distributions](#linux-distribution-specific-instructions), or the
 22  [dependencies](#dependencies) section for a complete overview.
 23  
 24  ## Memory Requirements
 25  
 26  C++ compilers are memory-hungry. It is recommended to have at least 1.5 GB of
 27  memory available when compiling Bitcoin Core. On systems with less, gcc can be
 28  tuned to conserve memory with additional `CMAKE_CXX_FLAGS`:
 29  
 30  
 31      cmake -B build -DCMAKE_CXX_FLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768"
 32  
 33  Alternatively, or in addition, debugging information can be skipped for compilation.
 34  For the default build type `RelWithDebInfo`, the default compile flags are
 35  `-O2 -g`, and can be changed with:
 36  
 37      cmake -B build -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g0"
 38  
 39  Finally, clang (often less resource hungry) can be used instead of gcc, which is used by default:
 40  
 41      cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
 42  
 43  ## Linux Distribution Specific Instructions
 44  
 45  ### Ubuntu & Debian
 46  
 47  #### Dependency Build Instructions
 48  
 49  Build requirements for the latest Debian "stable" release, or the latest Ubuntu LTS release:
 50  
 51      sudo apt-get install build-essential cmake pkgconf python3
 52  
 53  For Debian "oldstable", or earlier Ubuntu LTS releases, you may need to pick a
 54  later compiler version, according to the [dependencies](/doc/dependencies.md)
 55  documentation.
 56  
 57  Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies:
 58  
 59      sudo apt-get install libevent-dev libboost-dev
 60  
 61  SQLite is required for the wallet:
 62  
 63      sudo apt install libsqlite3-dev
 64  
 65  To build Bitcoin Core without the wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
 66  
 67  Cap'n Proto is needed for IPC functionality (see [multiprocess.md](multiprocess.md)):
 68  
 69      sudo apt-get install libcapnp-dev capnproto
 70  
 71  Compile with `-DENABLE_IPC=OFF` if you do not need IPC functionality.
 72  
 73  ZMQ-enabled binaries are compiled with `-DWITH_ZMQ=ON` and require the following dependency:
 74  
 75      sudo apt-get install libzmq3-dev
 76  
 77  User-Space, Statically Defined Tracing (USDT) dependencies:
 78  
 79      sudo apt install systemtap-sdt-dev
 80  
 81  GUI dependencies:
 82  
 83  Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
 84  the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
 85  
 86      sudo apt-get install qt6-base-dev qt6-tools-dev qt6-l10n-tools qt6-tools-dev-tools libgl-dev
 87  
 88  Additionally, to support Wayland protocol for modern desktop environments:
 89  
 90      sudo apt install qt6-wayland
 91  
 92  The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
 93  
 94      sudo apt-get install libqrencode-dev
 95  
 96  Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI.
 97  
 98  
 99  ### Fedora
100  
101  #### Dependency Build Instructions
102  
103  Build requirements:
104  
105      sudo dnf install gcc-c++ cmake make python3
106  
107  Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies:
108  
109      sudo dnf install libevent-devel boost-devel
110  
111  SQLite is required for the wallet:
112  
113      sudo dnf install sqlite-devel
114  
115  To build Bitcoin Core without the wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
116  
117  ZMQ-enabled binaries are compiled with `-DWITH_ZMQ=ON` and require the following dependency:
118  
119      sudo dnf install zeromq-devel
120  
121  User-Space, Statically Defined Tracing (USDT) dependencies:
122  
123      sudo dnf install systemtap-sdt-devel
124  
125  Cap'n Proto is needed for IPC functionality (see [multiprocess.md](multiprocess.md)):
126  
127      sudo dnf install capnproto capnproto-devel
128  
129  Compile with `-DENABLE_IPC=OFF` if you do not need IPC functionality.
130  
131  GUI dependencies:
132  
133  Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
134  the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
135  
136      sudo dnf install qt6-qtbase-devel qt6-qttools-devel
137  
138  Additionally, to support Wayland protocol for modern desktop environments:
139  
140      sudo dnf install qt6-qtwayland
141  
142  The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
143  
144      sudo dnf install qrencode-devel
145  
146  Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI.
147  
148  ### Alpine
149  
150  #### Dependency Build Instructions
151  
152  Build requirements:
153  
154      apk add build-base cmake linux-headers pkgconf python3
155  
156  Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies:
157  
158      apk add libevent-dev boost-dev
159  
160  SQLite is required for the wallet:
161  
162      apk add sqlite-dev
163  
164  To build Bitcoin Core without the wallet, see [*Disable-wallet mode*](#disable-wallet-mode)
165  
166  Cap'n Proto is needed for IPC functionality (see [multiprocess.md](multiprocess.md)):
167  
168      apk add capnproto capnproto-dev
169  
170  Compile with `-DENABLE_IPC=OFF` if you do not need IPC functionality.
171  
172  ZMQ dependencies (provides ZMQ API):
173  
174      apk add zeromq-dev
175  
176  User-Space, Statically Defined Tracing (USDT) is not supported or tested on Alpine Linux at this time.
177  
178  GUI dependencies:
179  
180  Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
181  the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
182  
183      apk add qt6-qtbase-dev  qt6-qttools-dev
184  
185  The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
186  
187      apk add libqrencode-dev
188  
189  Otherwise, if you don't need QR encoding support, use the `-DWITH_QRENCODE=OFF` option to disable this feature in order to compile the GUI.
190  
191  ## Dependencies
192  
193  See [dependencies.md](dependencies.md) for a complete overview, and
194  [depends](/depends/README.md) on how to compile them yourself, if you wish to
195  not use the packages of your Linux distribution.
196  
197  Disable-wallet mode
198  --------------------
199  When the intention is to only run a P2P node, without a wallet, Bitcoin Core can
200  be compiled in disable-wallet mode with:
201  
202      cmake -B build -DENABLE_WALLET=OFF
203  
204  In this case there is no dependency on SQLite.
205  
206  Mining is also possible in disable-wallet mode using the `getblocktemplate` RPC call.
207  
208  Setup and Build Example: Arch Linux
209  -----------------------------------
210  This example lists the steps necessary to setup and build a command line only distribution of the latest changes on Arch Linux:
211  
212      pacman --sync --needed capnproto cmake boost gcc git libevent make python sqlite
213      git clone https://github.com/bitcoin/bitcoin.git
214      cd bitcoin/
215      cmake -B build
216      cmake --build build
217      ctest --test-dir build
218      ./build/bin/bitcoind
219      ./build/bin/bitcoin help
220