3 Some notes on how to build Bitcoin in Unix.
5 (for OpenBSD specific instructions, see [build-openbsd.md](build-openbsd.md))
9 Always use absolute paths to configure and compile bitcoin and the dependencies,
10 for example, when specifying the the path of the dependency:
12 ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
14 Here BDB_PREFIX must absolute path - it is defined using $(pwd) which ensures
15 the usage of the absolute path.
24 make install # optional
27 This will build bitcoin-qt as well if the dependencies are met.
32 These dependencies are required:
34 Library | Purpose | Description
35 ------------|------------------|----------------------
36 libssl | Crypto | Random Number Generation, Elliptic Curve Cryptography
37 libboost | Utility | Library for threading, data structures, etc
38 libevent | Networking | OS independent asynchronous networking
40 Optional dependencies:
42 Library | Purpose | Description
43 ------------|------------------|----------------------
44 miniupnpc | UPnP Support | Firewall-jumping support
45 libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled)
46 qt | GUI | GUI toolkit (only needed when GUI enabled)
47 protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled)
48 libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled)
49 libzmq3 | ZMQ notification | Optional, allows generating ZMQ notifications (requires ZMQ version >= 4.x)
51 For the versions used in the release, see [release-process.md](release-process.md) under *Fetch and build inputs*.
56 C++ compilers are memory-hungry. It is recommended to have at least 1 GB of
57 memory available when compiling Bitcoin Core. With 512MB of memory or less
58 compilation will take much longer due to swap thrashing.
60 Dependency Build Instructions: Ubuntu & Debian
61 ----------------------------------------------
64 sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev libevent-dev
66 For Ubuntu 12.04 and later or Debian 7 and later libboost-all-dev has to be installed:
68 sudo apt-get install libboost-all-dev
70 db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin).
71 You can add the repository using the following command:
73 sudo add-apt-repository ppa:bitcoin/bitcoin
76 Ubuntu 12.04 and later have packages for libdb5.1-dev and libdb5.1++-dev,
77 but using these will break binary wallet compatibility, and is not recommended.
79 For other Debian & Ubuntu (with ppa):
81 sudo apt-get install libdb4.8-dev libdb4.8++-dev
85 sudo apt-get install libminiupnpc-dev (see --with-miniupnpc and --enable-upnp-default)
89 sudo apt-get install libzmq3-dev (provides ZMQ API 4.x)
92 Dependencies for the GUI: Ubuntu & Debian
93 -----------------------------------------
95 If you want to build Bitcoin-Qt, make sure that the required packages for Qt development
96 are installed. Either Qt 4 or Qt 5 are necessary to build the GUI.
97 If both Qt 4 and Qt 5 are installed, Qt 4 will be used. Pass `--with-gui=qt5` to configure to choose Qt5.
98 To build without GUI pass `--without-gui`.
100 To build with Qt 4 you need the following:
102 sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler
104 For Qt 5 you need the following:
106 sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
108 libqrencode (optional) can be installed with:
110 sudo apt-get install libqrencode-dev
112 Once these are installed, they will be found by configure and a bitcoin-qt executable will be
117 The release is built with GCC and then "strip bitcoind" to strip the debug
118 symbols, which reduces the executable size by about 90%.
124 [miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here](
125 http://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and
126 turned off by default. See the configure options for upnp behavior desired:
128 --without-miniupnpc No UPnP support miniupnp not required
129 --disable-upnp-default (the default) UPnP support turned off by default at runtime
130 --enable-upnp-default UPnP support turned on by default at runtime
134 tar -xzvf miniupnpc-1.6.tar.gz
143 It is recommended to use Berkeley DB 4.8. If you have to build it yourself:
148 # Pick some path to install BDB to, here we create a directory within the bitcoin directory
149 BDB_PREFIX="${BITCOIN_ROOT}/db4"
152 # Fetch the source and verify that it is not tampered with
153 wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
154 echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz' | sha256sum -c
155 # -> db-4.8.30.NC.tar.gz: OK
156 tar -xzvf db-4.8.30.NC.tar.gz
158 # Build the library and install to our prefix
159 cd db-4.8.30.NC/build_unix/
160 # Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime
161 ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
164 # Configure Bitcoin Core to use our own-built instance of BDB
167 ./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" # (other args...)
170 **Note**: You only need Berkeley DB if the wallet is enabled (see the section *Disable-Wallet mode* below).
174 If you need to build Boost yourself:
183 To help make your bitcoin installation more secure by making certain attacks impossible to
184 exploit even if a vulnerability is found, binaries are hardened by default.
185 This can be disabled with:
189 ./configure --enable-hardening
190 ./configure --disable-hardening
193 Hardening enables the following features:
195 * Position Independent Executable
196 Build position independent code to take advantage of Address Space Layout Randomization
197 offered by some kernels. Attackers who can cause execution of code at an arbitrary memory
198 location are thwarted if they don't know where anything useful is located.
199 The stack and heap are randomly located by default but this allows the code section to be
200 randomly located as well.
202 On an AMD64 processor where a library was not compiled with -fPIC, this will cause an error
203 such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;"
205 To test that you have built PIE executable, install scanelf, part of paxutils, and use:
209 The output should contain:
213 * Non-executable Stack
214 If the stack is executable then trivial stack based buffer overflow exploits are possible if
215 vulnerable buffers are found. By default, bitcoin should be built with a non-executable stack
216 but if one of the libraries it uses asks for an executable stack or someone makes a mistake
217 and uses a compiler extension which requires an executable stack, it will silently build an
218 executable without the non-executable stack protection.
220 To verify that the stack is non-executable after compiling use:
221 `scanelf -e ./bitcoin`
223 the output should contain:
227 The STK RW- means that the stack is readable and writeable but not executable.
231 When the intention is to run only a P2P node without a wallet, bitcoin may be compiled in
232 disable-wallet mode with:
234 ./configure --disable-wallet
236 In this case there is no dependency on Berkeley DB 4.8.
238 Mining is also possible in disable-wallet mode, but only using the `getblocktemplate` RPC