@@ -4,9 +4,9 @@ The HElib build, install, and regression tests suite have been built and tested
4
4
on Ubuntu 18.04, Ubuntu 20.04, Fedora 32, Fedora 33, CentOS 7.8, CentOS 8.2,
5
5
macOS Mojave >=10.14.6, and macOS Catalina >=10.15.7.
6
6
7
- There are two different ways to build and install HElib. The first one will
8
- automatically download and build the GMP and NTL dependencies and pack the
9
- libraries in a relocatable folder. The second way, instead, requires the
7
+ There are two different ways to build and install HElib. The first one will
8
+ automatically download and build the GMP and NTL dependencies and pack the
9
+ libraries in a relocatable folder. The second way, instead, requires the
10
10
dependencies to be installed by you and available in the system.
11
11
12
12
** Please read these instructions in full to better choose the type of build that
@@ -19,21 +19,24 @@ dependencies to be installed by you and available in the system.
19
19
- git >= 1.8.3 (required to build and run the HElib test suite)
20
20
21
21
** Linux environment:**
22
+
22
23
- g++ >= 7.3.1
23
24
- cmake >= 3.10.2
24
25
25
26
** macOS environment:**
27
+
26
28
- Apple clang >= 11.0.0 (available with the latest Xcode for the tested versions of macOS)
27
29
- Xcode Command Line Tools (can be installed with the command `xcode-select
28
30
--install` in a teminal)
29
31
- cmake >= 3.17.3 (available from [ CMake] ( https://cmake.org/ ) or [ MacPorts
30
32
Project] ( https://www.macports.org/ ) and [ Homebrew] ( https://brew.sh/ ) as
31
- packages)
33
+ packages)
32
34
33
35
** For development:**
36
+
34
37
- clang-format >= 9.0.0 (available with your linux distribution and for macOS
35
38
from [ MacPorts Project] ( https://www.macports.org/ ) and
36
- [ Homebrew] ( https://brew.sh/ ) as packages)
39
+ [ Homebrew] ( https://brew.sh/ ) as packages)
37
40
38
41
## Option 1: package build (recommended for most users)
39
42
@@ -42,137 +45,143 @@ which can then be moved around freely on the system. NTL and GMP will be
42
45
automatically fetched and compiled. It can be installed globally (i.e. under
43
46
` /usr/local ` ), which is the default option if no ` CMAKE_INSTALL_PREFIX ` is
44
47
specified, but this should only be done with caution as existing versions of
45
- NTL, GMP, or HElib will be overwritten. These additional two prerequisites
46
- are required in this case:
48
+ NTL, GMP, or HElib will be overwritten. These additional two prerequisites are
49
+ required in this case:
47
50
48
51
- m4 >= 1.4.16
49
52
- patchelf >= 0.9 (if building on Linux)
50
53
51
- Please note that if changing from library build to package build, it is safer
52
- to use a clean build directory.
54
+ Please note that if changing from library build to package build, it is safer to
55
+ use a clean build directory.
53
56
54
57
### Instructions
55
58
56
59
1 . Create a build directory, typically as a sibling of ` src ` :
57
- ```
60
+
61
+ ``` bash
58
62
cd HElib
59
63
mkdir build
60
64
cd build
61
65
```
62
66
63
67
2 . Run the cmake configuration step, specifying that you want a package build
64
- (via -DPACKAGE_BUILD=ON) and saying where you would like the installation to
65
- be. To install in ` /home/alice/helib_install ` , for example:
66
- ```
68
+ (via -DPACKAGE_BUILD=ON) and saying where you would like the installation to
69
+ be. To install in ` /home/alice/helib_install ` , for example:
70
+
71
+ ``` bash
67
72
cmake -DPACKAGE_BUILD=ON -DCMAKE_INSTALL_PREFIX=/home/alice/helib_install ..
68
73
```
69
74
70
- Extra options can be specified here, such as enabling HElib tests with
71
- ` -DENABLE_TEST=ON ` . See later section entitled "HElib build
72
- options" for details.
75
+ Extra options can be specified here, such as enabling HElib tests with
76
+ ` -DENABLE_TEST=ON ` . See later section entitled "HElib build options" for
77
+ details.
73
78
74
79
3 . Compile, with an optional number of threads specified (16 in this example).
75
- The output of this will be in the relocatable folder ` helib_pack ` :
76
- ```
80
+ The output of this will be in the relocatable folder ` helib_pack ` :
81
+
82
+ ``` bash
77
83
make -j16
78
84
```
79
85
80
- 4 . (optional) If step 2 was performed with ` -DENABLE_TEST=ON ` , HElib tests can
81
- be run as follows:
82
- ```
86
+ 4 . (optional) If step 2 was performed with ` -DENABLE_TEST=ON ` , HElib tests can
87
+ be run as follows:
88
+
89
+ ``` bash
83
90
ctest
84
91
```
85
- Detailed HElib-specific test logs can be found in
92
+
93
+ Detailed HElib-specific test logs can be found in
86
94
` Testing/Temporary/LastTest.log ` .
87
95
88
96
5 . (optional) Run the install step, to copy the folder ` helib_pack ` to
89
- ` ${CMAKE_INSTALL_PREFIX} ` (in this example ` /home/alice/helib_install ` ):
90
- ```
97
+ ` ${CMAKE_INSTALL_PREFIX} ` (in this example ` /home/alice/helib_install ` ):
98
+
99
+ ``` bash
91
100
make install
92
101
```
93
102
94
- of course, if the ` CMAKE_INSTALL_PREFIX ` was kept as the default ` /usr/local `
95
- or some other system-wide path, step 5 may require ` sudo ` privileges.
96
-
103
+ of course, if the ` CMAKE_INSTALL_PREFIX ` was kept as the default ` /usr/local ` or
104
+ some other system-wide path, step 5 may require ` sudo ` privileges.
97
105
98
106
## Option 2: library build (advanced)
99
107
100
108
This option involves building HElib on its own, linking against pre-existing
101
- dependencies (NTL and GMP) on the system. In this way, the HElib library can
102
- be moved around, but its dependencies (NTL and GMP) cannot, as they are
103
- absolute paths. For this option, you must build GMP >=6.0.0 and NTL >=11.4.3
104
- yourself. For details on how to do this, please see the section on building
105
- dependencies later. It is assumed throughout this installation option that the
106
- environment variables ` $GMPDIR ` and ` $NTLDIR ` are set to point to the
107
- installation directories of GMP and NTL respectively.
109
+ dependencies (NTL and GMP) on the system. In this way, the HElib library can be
110
+ moved around, but its dependencies (NTL and GMP) cannot, as they are absolute
111
+ paths. For this option, you must build GMP >=6.0.0 and NTL >=11.4.3 yourself.
112
+ For details on how to do this, please see the section on building dependencies
113
+ later. It is assumed throughout this installation option that the environment
114
+ variables ` $GMPDIR ` and ` $NTLDIR ` are set to point to the installation
115
+ directories of GMP and NTL respectively.
108
116
109
- Please note that if changing from package build to library build, it is safer
110
- to use a clean build directory.
117
+ Please note that if changing from package build to library build, it is safer to
118
+ use a clean build directory.
111
119
112
120
1 . Create a build directory, typically as a sibling of ` src ` :
113
121
114
-
115
- ```
122
+ ``` bash
116
123
cd HElib
117
124
mkdir build
118
125
cd build
119
126
```
120
127
121
128
2 . Run the cmake configuration step, specifying where to find NTL and GMP. If
122
- not specified, system-wide locations such as ` /usr/local/lib ` will be searched.
123
- To install in ` /home/alice/helib_install ` , for example:
129
+ not specified, system-wide locations such as ` /usr/local/lib ` will be
130
+ searched. To install in ` /home/alice/helib_install ` , for example:
124
131
125
- ```
132
+ ``` bash
126
133
cmake -DGMP_DIR=" ${GMPDIR} " -DNTL_DIR=" ${NTLDIR} " -DCMAKE_INSTALL_PREFIX=/home/alice/helib_install ..
127
134
```
128
135
129
- Extra options can be specified here, such as enabling HElib tests with
136
+ Extra options can be specified here, such as enabling HElib tests with
130
137
` -DENABLE_TEST=ON ` . See later section entitled "HElib build options" for
131
138
details.
132
139
133
140
3 . Compile, with an optional number of threads specified (16 in this example):
134
141
135
- ```
142
+ ``` bash
136
143
make -j16
137
144
```
138
145
139
146
4 . (optional) If step 2 was performed with ` -DENABLE_TEST=ON ` , tests can be run
140
- as follows:
141
- ```
147
+ as follows:
148
+
149
+ ``` bash
142
150
ctest
143
151
```
144
- Detailed HElib test logs can be found in
145
- ` Testing/Temporary/LastTest.log ` .
146
152
147
- 5 . Run the install step, to copy the files to ` ${CMAKE_INSTALL_PREFIX} ` (in
148
- this example ` /home/alice/helib_install ` ):
149
- ```
153
+ Detailed HElib test logs can be found in ` Testing/Temporary/LastTest.log ` .
154
+
155
+ 5 . Run the install step, to copy the files to ` ${CMAKE_INSTALL_PREFIX} ` (in this
156
+ example ` /home/alice/helib_install ` ):
157
+
158
+ ``` bash
150
159
make install
151
160
```
152
161
153
- of course, if the ` CMAKE_INSTALL_PREFIX ` was kept as the default ` /usr/local `
154
- or some other system-wide path, step 5 may require ` sudo ` privileges.
162
+ of course, if the ` CMAKE_INSTALL_PREFIX ` was kept as the default ` /usr/local ` or
163
+ some other system-wide path, step 5 may require ` sudo ` privileges.
155
164
156
165
## Building dependencies (for option 2)
157
166
158
167
### GMP
159
168
160
- Many distributions come with GMP pre-installed.
161
- If not, you can install GMP as follows.
169
+ Many distributions come with GMP pre-installed. If not, you can install GMP as
170
+ follows.
162
171
163
- 1 . Download GMP from http://www.gmplib.org -- make sure that you get GMP >=6.0.0
164
- (current version is 6.2.0).
172
+ 1 . Download GMP from [ http://www.gmplib.org ] ( http://www.gmplib.org ) -- make sure
173
+ that you get GMP >=6.0.0 (current version is 6.2.0).
165
174
2 . Decompress and cd into the gmp directory (e.g., ` gmp-6.2.0 ` ).
166
175
3 . GMP is compiled in the standard unix way:
167
- ```
176
+
177
+ ``` bash
168
178
./configure
169
179
make
170
180
sudo make install
171
181
```
172
182
173
183
This will install GMP into ` /usr/local ` by default.
174
184
175
-
176
185
** NOTE:** For further options when building GMP, run ` ./configure --help ` in
177
186
step 3.
178
187
@@ -181,15 +190,17 @@ step 3.
181
190
You can install NTL as follows:
182
191
183
192
1 . Download NTL >=11.4.3 (current version is 11.4.3) from
184
- http://www.shoup.net/ntl/download.html
193
+ [ http://www.shoup.net/ntl/download.html ] ( http://www.shoup.net/ntl/download.html )
185
194
2 . Decompress and cd into the directory, e.g., ` ntl-11.4.3/src `
186
- 3 . NTL is configured, built and installed in the standard Unix way (but
187
- remember to specify the following flags to ` configure ` ):
188
- ```
195
+ 3 . NTL is configured, built and installed in the standard Unix way (but remember
196
+ to specify the following flags to ` configure ` ):
197
+
198
+ ``` bash
189
199
./configure NTL_GMP_LIP=on SHARED=on NTL_THREADS=on NTL_THREAD_BOOST=on
190
200
make
191
201
sudo make install
192
202
```
203
+
193
204
This should install NTL into ` /usr/local ` .
194
205
195
206
** NOTE:** For further options when building NTL, run ` ./configure --help ` in
@@ -201,37 +212,40 @@ to the `./configure` step.
201
212
## HElib build options
202
213
203
214
### Generic options
204
- - ` BUILD_SHARED=ON/OFF ` (default is ` OFF ` ): Build as a shared library.
205
- Note that building HElib (regardless of ` BUILD_SHARED ` ) will fail if NTL
206
- is not built as a shared library. The default for NTL is static library,
207
- to build NTL as a shared library use ` ./configure SHARED=on ` in step 1.
208
- - ` CMAKE_BUILD_TYPE ` : (default is ` RelWithDebInfo ` ): Choose the type of build,
215
+
216
+ - ` BUILD_SHARED=ON/OFF ` (default is ` OFF ` ): Build as a shared library. Note that
217
+ building HElib (regardless of ` BUILD_SHARED ` ) will fail if NTL is not built as
218
+ a shared library. The default for NTL is static library, to build NTL as a
219
+ shared library use ` ./configure SHARED=on ` in step 1.
220
+ - ` CMAKE_BUILD_TYPE ` : (default is ` RelWithDebInfo ` ): Choose the type of build,
209
221
options are: ` Debug ` , ` RelWithDebInfo ` , ` Release ` , ` MinSizeRel ` .
210
222
- ` CMAKE_INSTALL_PREFIX ` : Desired installation directory for HElib.
211
223
- ` ENABLE_TEST=ON/OFF ` (default is ` OFF ` ): Enable building of tests. This will
212
- include an automatic download step for the google test framework stable
224
+ include an automatic download step for the google test framework stable
213
225
release (googletest v1.10.0)
214
226
- ` ENABLE_THREADS=ON/OFF ` (default is ` ON ` ): Enable threading support. This must
215
227
be on if and only if NTL was built with ` NTL_THREADS=ON ` .
216
- - ` PEDANTIC_BUILD=ON/OFF ` (default is ` ON ` ): Use
217
- ` -Wall -Wpedantic -Wextra -Werror` during build.
228
+ - ` PEDANTIC_BUILD=ON/OFF ` (default is ` ON ` ): Use `-Wall -Wpedantic -Wextra
229
+ -Werror` during build.
218
230
- ` HELIB_DEBUG=ON/OFF ` (default is ` OFF ` ): Activate the debug module when
219
- building HElib (by defining the ` HELIB_DEBUG ` macro). When the debug module
220
- is active, this generates extra information used for debugging purposes.
221
- ` HELIB_DEBUG ` will propagate to programs using HElib, when using cmake. When
231
+ building HElib (by defining the ` HELIB_DEBUG ` macro). When the debug module is
232
+ active, this generates extra information used for debugging purposes.
233
+ ` HELIB_DEBUG ` will propagate to programs using HElib, when using cmake. When
222
234
this is enabled, programs using HElib will generate a warning during
223
235
configuration. This is to remind the user that use of the debug module can
224
236
cause issues, such as ` sigsegv ` , if initialized incorrectly.
225
237
226
238
### Parameters specific to option 1 (package build)
239
+
227
240
- ` PACKAGE_DIR ` : Location that a package build will be installed to. Defaults
228
- to ` ${CMAKE_INSTALL_PREFIX}/helib_pack ` .
229
- - ` FETCH_GMP ` : Whether or not to fetch and build GMP. Defaults to ` ON ` . If
230
- set to ` OFF ` , there should either exist a system-installed GMP library, or
231
- ` GMP_DIR ` should point to a valid GMP prefix.
241
+ to ` ${CMAKE_INSTALL_PREFIX}/helib_pack ` .
242
+ - ` FETCH_GMP ` : Whether or not to fetch and build GMP. Defaults to ` ON ` . If set
243
+ to ` OFF ` , there should either exist a system-installed GMP library, or
244
+ ` GMP_DIR ` should point to a valid GMP prefix.
232
245
- ` GMP_DIR ` : Prefix of the GMP library. Ignored if ` FETCH_GMP=ON ` .
233
246
234
247
### Parameters specific to option 2 (library build)
248
+
235
249
- ` GMP_DIR ` : Prefix of the GMP library.
236
250
- ` NTL_DIR ` : Prefix of the NTL library.
237
251
@@ -249,13 +263,15 @@ choice.
249
263
Another, easier way is possible if you are using HElib in a cmake project.
250
264
251
265
1 . Include the following line in your ` CMakeLists.txt ` :
252
- ```
266
+
267
+ ``` cmake
253
268
find_package(helib)
254
269
```
270
+
255
271
2 . Run your ` cmake ` step with
256
272
` -Dhelib_DIR=<helib install prefix>/share/cmake/helib ` .
257
273
258
274
## Example
259
275
260
- Full working examples of cmake-based projects which uses HElib can be found
261
- in the ` examples ` directory.
276
+ Full working examples of cmake-based projects which uses HElib can be found in
277
+ the ` examples ` directory.
0 commit comments