ubuntu下使用NDK编译可执行程序的环境搭建
2018-03-21 13:25
337 查看
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安全检测,因此需要绕过该机制,程序才能执行
解决办法:https://bbs.pediy.com/thread-213790.htm,该方法不能覆盖linker
则修改源码,通过关键字符串找到源码位置,bionic/linker/linker.cpp
再重新编译源码//初始化编译环境
source build/envsetup.sh
//使用 lunch 命令选择编译目标:
lunch
//使用 make 命令进行构建
make -j45.刷机测试
略
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安全检测,因此需要绕过该机制,程序才能执行
解决办法:https://bbs.pediy.com/thread-213790.htm,该方法不能覆盖linker
则修改源码,通过关键字符串找到源码位置,bionic/linker/linker.cpp
再重新编译源码//初始化编译环境
source build/envsetup.sh
//使用 lunch 命令选择编译目标:
lunch
//使用 make 命令进行构建
make -j45.刷机测试
略
相关文章推荐
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu10.04搭建linux-0.11编译环境(1.bochs安装和使用)
- ubuntu9.10使用第一天(教育网直通车+源修改+C++编译环境搭建+输入法安装)
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- [转]Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- ANDROID NDK实践开发系列--(01) 使用ndk编译c可执行程序
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- 搭建Window环境下android NDK开发环境——编译第一个NDK程序
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境
- Ubuntu 12.04 使用Eclipse搭建C/C++编译环境
- Ubuntu(Linux)使用Eclipse搭建C/C++编译环境