a C++ code built into a shared library for HELib is using NTL and GMP static library. But it gets following error:
/usr/bin/ld: /usr/local/lib/libntl.a(FFT.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libntl.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status
It was suggested int the post Click here
to recompile NTL and GMP with "-fPIC " flags. I'am not able to find how I should do that.
Edit:
I'm able to build the shared library now after :
recompiling GMP and NTL by:
./configure --enable-shared
for gmp and
./configure SHARED=on
After make Install of HELib. I get error when I run the example codes. The link to the Makefile : click to see makefile
Error:
g++ -g -O2 -std=c++11 -pthread -DFHE_THREADS -DFHE_BOOT_THREADS -DFHE_DCRT_THREADS -o Test_General_x Test_General.cpp -L/usr/local/lib -lntl -lgmp -lm -lfhe /usr/local/lib/libfhe.so: undefined reference to
write_raw_int(std::ostream&, long, long)' /usr/local/lib/libfhe.so: undefined reference to
read_raw_ZZ(std::istream&, NTL::ZZ&)' /usr/local/lib/libfhe.so: undefined reference tovoid write_raw_vector<long>(std::ostream&, std::vector<long, std::allocator<long> > const&)' /usr/local/lib/libfhe.so: undefined reference to
writeEyeCatcher(std::ostream&, char const*)' /usr/local/lib/libfhe.so: undefined reference towrite_raw_xdouble(std::ostream&, NTL::xdouble)' /usr/local/lib/libfhe.so: undefined reference to
read_ntl_vec_long(std::istream&, NTL::Vec&)' /usr/local/lib/libfhe.so: undefined reference tovoid read_raw_vector<long>(std::istream&, std::vector<long, std::allocator<long> >&)' /usr/local/lib/libfhe.so: undefined reference to
readEyeCatcher(std::istream&, char const*)' /usr/local/lib/libfhe.so: undefined reference toread_raw_int(std::istream&, long)' /usr/local/lib/libfhe.so: undefined reference to
read_raw_xdouble(std::istream&)' /usr/local/lib/libfhe.so: undefined reference towrite_raw_ZZ(std::ostream&, NTL::ZZ const&)' /usr/local/lib/libfhe.so: undefined reference to
write_ntl_vec_long(std::ostream&, NTL::Vec const&, long)' collect2: error: ld returned 1 exit status Makefile:179: recipe for target 'Test_General_x' failed make: *** [Test_General_x] Error 1
.../configure --help
gives the answer... – Marc Glisse./configure --help | grep -i pic
. – Marc Glissenm -CD /usr/local/lib/libfhe.so
and see what looks closest to those undefined references. – Marc Glisse