apt-get install patchelf
sudo apt-get update
sudo apt-get install build-essential software-properties-common -y
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install gcc-snapshot -y
sudo apt-get update
sudo apt-get install gcc-9 g++-9 -y
执行cmake .. 报错
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
GMP required dynamic shared library has not been found in
/root/gmp-6.2.1/.libs.: Found unsuitable version "6.1.2", but required is
at least "6.2.0" (found /usr/lib/x86_64-linux-gnu/libgmp.so)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:391 (_FPHSA_FAILURE_MESSAGE)
cmake/FindGMP.cmake:123 (find_package_handle_standard_args)
CMakeLists.txt:322 (find_package)
-- Configuring incomplete, errors occurred!
See also "/root/HElib-master/build/CMakeFiles/CMakeOutput.log".
See also "/root/HElib-master/build/CMakeFiles/CMakeError.log".
解决方案就是深入到cmake的源文件中去看:
if (GMP_DIR)
# If user-specified folders: look there
find_library(GMP_LIB
NAMES gmp libgmp
PATHS ${GMP_DIR}
PATH_SUFFIXES ${lib_suffixes}
NO_DEFAULT_PATH
DOC "GMP library")
# Headers here are only to check version
find_path(GMP_HEADERS
NAMES gmp.h
PATHS ${GMP_DIR}
PATH_SUFFIXES ${header_suffixes}
NO_DEFAULT_PATH
DOC "GMP headers")
else (GMP_DIR)
# Else: look in default paths
find_library(GMP_LIB
NAMES gmp libgmp
PATH_SUFFIXES ${lib_suffixes}
DOC "GMP library")
# Headers here are only to check version
find_path(GMP_HEADERS
NAMES gmp.h
PATH_SUFFIXES ${header_suffixes}
DOC "GMP headers")
endif (GMP_DIR)
这里面不仅仅需要定义GMP_DIR,还要定义GMP_HEADERS和GMP_LIB
如下所示:
cmake -DGMP_DIR=/root/gmp-6.2.1 -DGMP_LIB=/root/gmp-6.2.1/.libs -DGMP_HEADERS=/root/gmp-6.2.1 -DPACKAGE_BUILD=ON -DCMAKE_INSTALL_PREFIX=/home/helib_install ..
继续执行上面的命令,NTL库也是同样的问题,手工下载NTL后进行编译
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
NTL required dynamic shared library has not been found. (Try cmake
-DNTL_DIR=<NTL-root-path>). (missing: NTL_LIB NTL_HEADERS) (Required is at
least version "11.4.3")
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
cmake/FindNTL.cmake:110 (find_package_handle_standard_args)
CMakeLists.txt:328 (find_package)
-- Configuring incomplete, errors occurred!
See also "/root/HElib-master/build/CMakeFiles/CMakeOutput.log".
See also "/root/HElib-master/build/CMakeFiles/CMakeError.log".
make[1]: Leaving directory '/root/ntl-11.5.1/src'
make setup3
make[1]: Entering directory '/root/ntl-11.5.1/src'
g++ -I../include -I. -g -O2 -pthread -march=native -o gen_gmp_aux gen_gmp_aux.cpp -lgmp -lm
./gen_gmp_aux > ../include/NTL/gmp_aux.h
NTL_GMP_LIP flag set
GMP version check (6.1.2/6.2.1)
*** version number mismatch: inconsistency between gmp.h and libgmp
Aborted (core dumped)
makefile:360: recipe for target 'setup3' failed
make[1]: *** [setup3] Error 134
make[1]: Leaving directory '/root/ntl-11.5.1/src'
makefile:324: recipe for target 'setup-phase' failed
make: *** [setup-phase] Error 2
再/root/gmp-6.2.1目录中把.libs目录重命名为libs, 把头文件都复制到 /root/gmp-6.2.1/include中
然后在执行如下命令即可:
cd /root/ntl-11.5.1/src
./configure GMP_PREFIX=/root/gmp-6.2.1
make
make install
最后再重新执行
cmake -DGMP_DIR=/root/gmp-6.2.1 -DGMP_LIB=/root/gmp-6.2.1/.libs -DGMP_HEADERS=/root/gmp-6.2.1 -DPACKAGE_BUILD=ON -DCMAKE_INSTALL_PREFIX=/home/helib_install ..
编译examples
cd /root/HElib-2.2.0/examples
mkdir build
cd build
cmake -Dhelib_DIR=/home/helib_install/helib_pack/share/cmake/helib ..
make