1.首先是通过下面链接的高级方法生成自定义编译的工具链
https://developer.android.google.cn/ndk/guides/standalone_toolchain.html#wwc
2.编写c源码
3.使用下面命令编译
arm-linux-androideabi-gcc -o hello hello.c -fPIE -pie --target=mandroid –static
或者
gedit /etc/profile
#添加环境变量CC
export CC=arm-linux-androideabi-gcc
source
$CC –o hello hello.c -fPIE
参考链接:https://www.findhao.net/easycoding/1475
4.接下来生成了arm平台的可执行文件,push到手机执行会报错,
error: only position independent executables (PIE) are supported.
这是在android L之后linker开启了PIE安全检测