homenc / HElib

HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
https://homenc.github.io/HElib
Other
3.11k stars 761 forks source link

How to run a customized progrom like exmple_program? #322

Closed qianlou closed 4 years ago

qianlou commented 4 years ago

Your Contact: Your environment (OS/HW): Detailed Description: I can run the example_program/helib_example.cpp, but how can I run a other file. What do I need to learn? I am a beginner in Cmake. when I tried to use g++ to compile one .cpp file, I can generate the .o file, but I can't not generate executable file using command (g++ -std=c++17 -O2 -Wall -pthread binary_compare.o -o binary_compare -L /usr/local/helib_pack/lib -lntl -lgmp -lm -I /usr/local/helib_pack/include/helib/) because of link errors like( Test_binaryCompare.cpp:(.text+0x28f): undefined reference to ArgMap::parse(int, char**)' Test_binaryCompare.cpp:(.text+0x6d5): undefined reference toFHEcontext::FHEcontext(unsigned long, unsigned long, unsigned long, std::vector<long, std::allocator > const&, std::vector<long, std::allocator > const&)' )

jlhcrawford commented 4 years ago

@qianlou At the bottom of https://github.com/homenc/HElib/blob/master/INSTALL.md it describes how to build your own project.

During the HElib build and install step you run cmake (from HElib/build) with the flag -DCMAKE_INSTALL_PREFIX=<helib install path> to specify where you want to install HElib.

In your own project directory e.g. my_project write a CMakeLists.txt that is similar to the one in HElib/example_program changing the necessary lines to be specific to your own test program. For example add_executable(my_program, my_program.cpp) and target_link_libraries(my_program helib).

Then create a build directory local to your program and run cmake .. with the flag -Dhelib_DIR=<helib install path>/share/cmake/helib from my_project/build.

qianlou commented 4 years ago

Thanks for your help. This method works for me.