intel / pailliercryptolib

Intel Paillier Cryptosystem Library is an open-source library which provides accelerated performance of a partial homomorphic encryption (HE), named Paillier cryptosystem, by utilizing Intel® IPP-Crypto on AVX512IFMA instructions. Intel Paillier Cryptosystem Library is certified for ISO compliance.
Apache License 2.0
73 stars 18 forks source link

Build(CMake) error for serialization: libippcp.so.11: error adding symbols: DSO missing from command line #80

Closed lzjluzijie closed 6 months ago

lzjluzijie commented 6 months ago

My CMake project link this library by

find_package(IPCL 2.0.0
        HINTS /opt/intel/ipcl1
        REQUIRED)
target_link_libraries(project IPCL::ipcl)

and I can use encrypt/decrypt normally.

However, if I add serialization

void testSerialize() {
  const uint32_t num_values = 1;

  std::random_device dev;
  std::mt19937 rng(dev());
  std::uniform_int_distribution<std::mt19937::result_type> dist(0, UINT_MAX);

  std::vector<uint32_t> exp_value(num_values);
  std::for_each(exp_value.begin(), exp_value.end(),
                [&](uint32_t& n) { n = dist(rng); });

  ipcl::PlainText pt = ipcl::PlainText(exp_value);
  std::ostringstream os;
  ipcl::serializer::serialize(os, pt);

CMake will throw error

[ 33%] Linking CXX executable
/usr/bin/ld: CMakeFiles/project.dir/src/test.cpp.o: undefined reference to symbol 'ippsRef_BN'
/usr/bin/ld: /opt/intel/ipcl1/lib/ipcl/ippcrypto/libippcp.so.11: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

If I comment out line ipcl::serializer::serialize(os, pt);, it will build successfully.

I am not very familiar with cpp/cmake. I am able to build the library and all unit tests including serialization tests. I think my CMakeLists.txt might be wrong, but I don't know how to fix it. Thank you for any suggestion.

lzjluzijie commented 6 months ago

OK I solved this issue. It seems ippcrypto is not installed to the target directory when install this project. I added

find_package(IPPCP
        HINTS pailliercryptolib/build1/ext_ipp-crypto/ippcrypto_install/opt/intel/ipcl1/
        REQUIRED)
target_link_libraries(projectIPPCP::ippcp)

and it worked.