创建动态链接是链接静态库报错
创建一个动态库时报错,如下
relocation R_X86_64_32 against `vtable for Base' can not be used when making a shared object; recompile with -fPIC
../sdk/lib/libbase.a: could not read symbols: Bad value
因为其中链接了一个静态库libbase.a
g++ -fPIC -shared -I../sdk/include load.cpp helper.cpp ../sdk/lib/libbase.a -o load.so
而创建Libbase.a是没有加-fPIC参数,导致报错。
所以在创建libbase.a时加上-fPIC即可