relocation 错误

icc test/train/test_lm2.o -shared -lpthread -ldl ./lib/liblm2.a -o liblm2.so

ld: ./lib/liblm2.a(cJSON.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
./lib/liblm2.a: could not read symbols: Bad value

错误原因:静态库里面cJSON.c 编译没有加-fPIC

原文地址:https://www.cnblogs.com/tibetanmastiff/p/5810396.html