openfhe-rs icon indicating copy to clipboard operation
openfhe-rs copied to clipboard

Error when building with "Custom crate installation from the source"

Open minnow54426 opened this issue 1 year ago • 6 comments

Hello, I got an error when running

cargo build

which say that

openfhe-rs/target/debug/build/openfhe-f060a627b59bf248/out/cxxbridge/crate/openfhe/src/SerialDeserial.h:3:10: fatal error: 'bits/stringfwd.h' file not found
warning: [email protected]: #include "bits/stringfwd.h"
warning: [email protected]:          ^~~~~~~~~~~~~~~~~~
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `openfhe v0.1.5 (/Users/lihao/code/rust/openfhe-rs)`

My cmake version is 3.29.0, clang version is 15.0.0 and cargo version is 1.78.0 in MacBook pro with M3.

minnow54426 avatar Jun 13 '24 09:06 minnow54426

It seems that this file is distributed with GCC.

minnow54426 avatar Jun 13 '24 10:06 minnow54426

Thanks for the problem! I'm working on it.

HovsepPapoyan avatar Jun 13 '24 10:06 HovsepPapoyan

I updated the master, please try building again.

HovsepPapoyan avatar Jun 13 '24 10:06 HovsepPapoyan

Sorry for late response. The new master can run cargo build successfully, great! There is still some issue with cargo test and cargo run with examples, the error is

Compiling openfhe v0.1.5 
error: linking with `cc` failed: exit status: 1

and the note is

note: ld: unknown options: -rpath=/usr/local/lib 
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks very much!

minnow54426 avatar Jun 14 '24 01:06 minnow54426

Some further information. ChatGPT suggests to replace

println!("cargo::rustc-link-arg=-Wl,-rpath=/usr/local/lib");

with

println!("cargo::rustc-link-arg=-Wl,-rpath,/usr/local/lib");

which replace "=" with ",", then, after rebuild, test introduce a new error

ld: warning: object file (/Users/openfhe-rs/target/debug/build/openfhe-012c5e72e626bb2b/out/libopenfhe.a[2](3a03b8d1686208bd-lib.rs.o)) was built for newer 'macOS' version (14.4) than being linked (14.0)

Then I add a new line to build.rs

println!("cargo::rustc-env=MACOSX_DEPLOYMENT_TARGET=14.4");

Finally the error with test becomes

ld: warning: search path './openfhe-development/install/lib' not found
          Undefined symbols for architecture arm64:
            "lbcrypto::PseudoRandomNumberGenerator::m_prng", referenced from:
                lbcrypto::PseudoRandomNumberGenerator::GetPRNG() in libopenfhe.a[5](2e40c9e35e9506f4-CryptoContext.o)
                lbcrypto::PseudoRandomNumberGenerator::GetPRNG() in libopenfhe.a[5](2e40c9e35e9506f4-CryptoContext.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I go to C++ version of openFHE and checked, m_prng does exist and is defined in namespace lbcrypto as follows

std::shared_ptr<PRNG> PseudoRandomNumberGenerator::m_prng = nullptr;

I have been used C++ version of openFHE via cmake for a long time, and nothing is wrong with this m_prng.

minnow54426 avatar Jun 14 '24 02:06 minnow54426

I am experiencing the same error about "Undefined symbols" reported above with the current version in main. Any ideas/workarounds?

navasvarela avatar Oct 17 '24 10:10 navasvarela