]> Git Repo - VerusCoin.git/blame - doc/build-unix.md
Missing from Documentation Index
[VerusCoin.git] / doc / build-unix.md
CommitLineData
0a61b0df 1UNIX BUILD NOTES
2341e9b5 2====================
00a88745 3Some notes on how to build Bitcoin in Unix.
0a61b0df 4
f701da8f
KZ
5Note
6---------------------
7Always use absolute paths to configure and compile bitcoin and the dependencies,
8for example, when specifying the the path of the dependency:
9
10 ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
11
12Here BDB_PREFIX must absolute path - it is defined using $(pwd) which ensures
13the usage of the absolute path.
14
b1a657a0 15To Build
2341e9b5 16---------------------
b1a657a0 17
f60dc15c
W
18```bash
19./autogen.sh
20./configure
21make
22make install # optional
23```
84c3fb07 24
35b8af92 25This will build bitcoin-qt as well if the dependencies are met.
b1a657a0 26
0a61b0df 27Dependencies
2341e9b5 28---------------------
7b465b66 29
b5d1b109
WL
30These dependencies are required:
31
a75cacda
TH
32 Library | Purpose | Description
33 ------------|------------------|----------------------
34 libssl | SSL Support | Secure communications
a75cacda 35 libboost | Boost | C++ Library
2341e9b5 36
b5d1b109 37Optional dependencies:
7b465b66 38
b5d1b109
WL
39 Library | Purpose | Description
40 ------------|------------------|----------------------
41 miniupnpc | UPnP Support | Firewall-jumping support
42 libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled)
43 qt | GUI | GUI toolkit (only needed when GUI enabled)
44 protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled)
45 libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled)
7b465b66 46
b5d1b109 47For the versions used in the release, see [release-process.md](release-process.md) under *Fetch and build inputs*.
7b465b66 48
4babd081
WL
49System requirements
50--------------------
51
52C++ compilers are memory-hungry. It is recommended to have at least 1 GB of
53memory available when compiling Bitcoin Core. With 512MB of memory or less
54compilation will take much longer due to swap thrashing.
55
7b465b66 56Dependency Build Instructions: Ubuntu & Debian
57----------------------------------------------
a21bdda7 58Build requirements:
2341e9b5 59
ffe32914 60 sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
e5f0247b 61
347a3a3e 62for Ubuntu 12.04 and later or Debian 7 and later libboost-all-dev has to be installed:
a21bdda7 63
2341e9b5 64 sudo apt-get install libboost-all-dev
65
66 db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin).
f8a7b503
D
67 You can add the repository using the following command:
68
69 sudo add-apt-repository ppa:bitcoin/bitcoin
70 sudo apt-get update
a21bdda7 71
29a41463 72 Ubuntu 12.04 and later have packages for libdb5.1-dev and libdb5.1++-dev,
a21bdda7 73 but using these will break binary wallet compatibility, and is not recommended.
6603b09e 74
749f8f81
IK
75for Debian 7 (Wheezy) and later:
76 The oldstable repository contains db4.8 packages.
77 Add the following line to /etc/apt/sources.list,
78 replacing [mirror] with any official debian mirror.
79
80 deb http://[mirror]/debian/ oldstable main
6603b09e 81
749f8f81
IK
82To enable the change run
83
84 sudo apt-get update
85
d618965e 86for other Debian & Ubuntu (with ppa):
2341e9b5 87
e5f0247b 88 sudo apt-get install libdb4.8-dev libdb4.8++-dev
a21bdda7 89
90Optional:
2341e9b5 91
35b8af92 92 sudo apt-get install libminiupnpc-dev (see --with-miniupnpc and --enable-upnp-default)
0a61b0df 93
29a41463
WL
94Dependencies for the GUI: Ubuntu & Debian
95-----------------------------------------
96
97If you want to build Bitcoin-Qt, make sure that the required packages for Qt development
54d2b91c
WL
98are installed. Either Qt 4 or Qt 5 are necessary to build the GUI.
99If both Qt 4 and Qt 5 are installed, Qt 4 will be used. Pass `--with-gui=qt5` to configure to choose Qt5.
100To build without GUI pass `--without-gui`.
29a41463
WL
101
102To build with Qt 4 you need the following:
103
7211bceb 104 sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler
29a41463 105
54d2b91c
WL
106For Qt 5 you need the following:
107
be7b0bff 108 sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
54d2b91c 109
29a41463
WL
110libqrencode (optional) can be installed with:
111
7211bceb 112 sudo apt-get install libqrencode-dev
29a41463
WL
113
114Once these are installed, they will be found by configure and a bitcoin-qt executable will be
115built by default.
8bb5edc1 116
0a61b0df 117Notes
118-----
7b465b66 119The release is built with GCC and then "strip bitcoind" to strip the debug
0a61b0df 120symbols, which reduces the executable size by about 90%.
121
122
8bb5edc1
MC
123miniupnpc
124---------
b5d1b109
WL
125
126[miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here](
127http://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and
128turned off by default. See the configure options for upnp behavior desired:
129
130 --without-miniupnpc No UPnP support miniupnp not required
131 --disable-upnp-default (the default) UPnP support turned off by default at runtime
132 --enable-upnp-default UPnP support turned on by default at runtime
133
134To build:
135
2341e9b5 136 tar -xzvf miniupnpc-1.6.tar.gz
137 cd miniupnpc-1.6
138 make
139 sudo su
140 make install
8bb5edc1
MC
141
142
0a61b0df 143Berkeley DB
144-----------
bfb154e9
WL
145It is recommended to use Berkeley DB 4.8. If you have to build it yourself:
146
147```bash
148BITCOIN_ROOT=$(pwd)
149
150# Pick some path to install BDB to, here we create a directory within the bitcoin directory
151BDB_PREFIX="${BITCOIN_ROOT}/db4"
152mkdir -p $BDB_PREFIX
153
154# Fetch the source and verify that it is not tampered with
155wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
156echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz' | sha256sum -c
157# -> db-4.8.30.NC.tar.gz: OK
158tar -xzvf db-4.8.30.NC.tar.gz
159
160# Build the library and install to our prefix
161cd db-4.8.30.NC/build_unix/
3800135a 162# Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime
bfb154e9
WL
163../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
164make install
165
166# Configure Bitcoin Core to use our own-built instance of BDB
167cd $BITCOIN_ROOT
168./configure (other args...) LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/"
169```
0a61b0df 170
bfb154e9 171**Note**: You only need Berkeley DB if the wallet is enabled (see the section *Disable-Wallet mode* below).
0a61b0df 172
173Boost
174-----
175If you need to build Boost yourself:
2341e9b5 176
177 sudo su
178 ./bootstrap.sh
179 ./bjam install
3f94dfa2 180
181
182Security
183--------
184To help make your bitcoin installation more secure by making certain attacks impossible to
35b8af92
CF
185exploit even if a vulnerability is found, binaries are hardened by default.
186This can be disabled with:
187
08b93f9a
H
188Hardening Flags:
189
190 ./configure --enable-hardening
191 ./configure --disable-hardening
35b8af92
CF
192
193
194Hardening enables the following features:
3f94dfa2 195
196* Position Independent Executable
197 Build position independent code to take advantage of Address Space Layout Randomization
7e6d23b1
CD
198 offered by some kernels. Attackers who can cause execution of code at an arbitrary memory
199 location are thwarted if they don't know where anything useful is located.
3f94dfa2 200 The stack and heap are randomly located by default but this allows the code section to be
201 randomly located as well.
202
7e6d23b1 203 On an AMD64 processor where a library was not compiled with -fPIC, this will cause an error
3f94dfa2 204 such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;"
205
3f94dfa2 206 To test that you have built PIE executable, install scanelf, part of paxutils, and use:
2341e9b5 207
208 scanelf -e ./bitcoin
3f94dfa2 209
210 The output should contain:
211 TYPE
212 ET_DYN
213
214* Non-executable Stack
215 If the stack is executable then trivial stack based buffer overflow exploits are possible if
216 vulnerable buffers are found. By default, bitcoin should be built with a non-executable stack
217 but if one of the libraries it uses asks for an executable stack or someone makes a mistake
218 and uses a compiler extension which requires an executable stack, it will silently build an
219 executable without the non-executable stack protection.
220
221 To verify that the stack is non-executable after compiling use:
2341e9b5 222 `scanelf -e ./bitcoin`
3f94dfa2 223
224 the output should contain:
2341e9b5 225 STK/REL/PTL
226 RW- R-- RW-
3f94dfa2 227
228 The STK RW- means that the stack is readable and writeable but not executable.
ae6ea5a6
WL
229
230Disable-wallet mode
231--------------------
232When the intention is to run only a P2P node without a wallet, bitcoin may be compiled in
233disable-wallet mode with:
234
235 ./configure --disable-wallet
236
237In this case there is no dependency on Berkeley DB 4.8.
4a85e067
WL
238
239Mining is also possible in disable-wallet mode, but only using the `getblocktemplate` RPC
240call not `getwork`.
241
This page took 0.224003 seconds and 4 git commands to generate.