码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2017-08-30 10:59:39      阅读:958      评论:0      收藏:0      [点我收藏+]

标签:开启   显示   ase   class   and   android   ble   验证   ace   

由于使用了NDK编译的可执行文件在应用中调用,在Android 7.0上的运行情况发现,当运行该可执行文件时,报如下错误:

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
LOCAL_LDFLAGS += -Wl,--fatal-warnings

 linker_flags = ‘ -Wl,--no-wchar-size-warning ‘,

 

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

标签:开启   显示   ase   class   and   android   ble   验证   ace   

原文地址:http://www.cnblogs.com/wangmh/p/7450234.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!