【转】NDK编译可执行文件在Android L中运行显示error: only position independent executables (PIE) are supported.失败问题解决办法。------不错

原文网址:http://blog.csdn.net/hxdanya/article/details/39371759

由于使用了NDK编译的可执行文件在应用中调用,在4.4及之前的版本上一直没出问题。最近由于要测试在Android L上的运行情况发现,当运行该可执行文件时,报如下错误:

 

error: only position independent executables (PIE) are supported.

 

PIE这个安全机制从4.1引入,但是Android L之前的系统版本并不会去检验可执行文件是否基于PIE编译出的。因此不会报错。但是Android L已经开启验证,如果调用的可执行文件不是基于PIE方式编译的,则无法运行。解决办法非常简单,在Android.mk中加入如下flag就行。

 

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE

posted on 2015-06-03 15:28  wi100sh  阅读(3431)  评论(0编辑  收藏  举报

导航