libtommath.a: could not read symbols: Bad value 编译错误

最近做个项目需要RSA,便调用了tommath,平时开发环境都在32位的系统上,编译运行一切都没问题,但当把程序换到一台64位系统上编译时出现:

/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libtommath.a(bn_mp_init.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libtommath.a: could not read symbols: Bad value

看来在64位系统编译libtommath时需要加-fPIC,于是修改makefile在CFLAGS里追加上-fPIC,重新编译libtommath后安装,此时再编译自己的程序,问题解决!

原文地址:https://www.cnblogs.com/xiaoleiel/p/8296300.html