原文:http://www.itdadao.com/articles/c15a324479p0.html
在Android6.0+系统,app编译时TargetAPI>22时,加载一些so出现has text relocations的问题处理方法:
在linux系统下使用eu-findtextrel命令可以查看问题所在地方,如下:
1. add -static -fPIC to .a lib build compile flags 2. android so Android.mk LOCAL_CFLAGS += -shared -fPIC LOCAL_LDFLAGS += -shared -fPIC eu-findtextrel xx.so suker@suker-Lenovo-Y430P:armeabi$ eu-findtextrel xx.so either the file containing the function 'xxx_arm' or the file containing the function '__cxa_thread_atexit' is not compiled with -fpic/-fPIC ... fixed build option until suker@suker-Lenovo-Y430P:armeabi$ eu-findtextrel xx.so eu-findtextrel: no text relocations reported in 'xx.so' suker@suker-Lenovo-Y430P:armeabi$
注意:有时候加了-fPIC选项编译,但是还是会出现警告提示框,这时可能是由于一些库的汇编代码引起的,可以--disable-asm重新编译尝试