内置于HELib共享库中的C ++代码正在使用NTL和GMP静态库。但出现以下错误:
/ usr / bin / ld:/usr/local/lib/libntl.a(FFT.o):在创建共享库时,不能将R_X86_64_32相对于'.rodata.str1.8'进行重定位;用-fPIC
重新编译 /usr/local/lib/libntl.a:添加符号时出错:值错误 collect2:错误:ld返回1退出状态
建议在帖子中点击here
用“ -fPIC”标志重新编译NTL和GMP。 我找不到应该怎么做。
编辑:
我现在可以在构建共享库之后:
通过以下方式重新编译GMP和NTL:
./configure --enable-shared
对于gmp和
./configure SHARED=on
在安装HELib之后。运行示例代码时出现错误。 Makefile的链接:click to see makefile
错误:
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:对
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:对void 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:对write_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:对void 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:对read_raw_int(std::istream&, long)' /usr/local/lib/libfhe.so: undefined reference to
read_raw_xdouble(std :: istream&)的未定义引用 /usr/local/lib/libfhe.so:对write_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:错误:ld返回1退出状态 Makefile:179:目标“ Test_General_x”的配方失败 make:*** [Test_General_x]错误1
答案 0 :(得分:0)
Marc Glisse为问题的前两部分提供了答案。对于第三部分“未定义的引用错误”,答案是我没有编译并将包含导致未定义的引用的函数的x.cpp链接到我的共享库。因此,请检查:nm -CD /usr/local/lib/libfhe.so以查看这些功能是否带有链接地址。如果没有,请检查哪个代码提供此功能。将该代码链接到共享库。