设为首页 加入收藏

TOP

使用Android NDK中的独立toolchain来开发C/C++程序
2014-11-24 12:40:08 来源: 作者: 【 】 浏览:0
Tags:使用 Android NDK 独立 toolchain 开发 C/C 程序

其实Android的NDK自带了toolchain,但是不能直接使用NDK目录内的toolchain,否则会出现找不到crtbegin_dynamic.o文件。


即使用-L指定目录或者直接放到gcc命令行也还是提示该文件找不到。(参考最后附上的链接)。


其实Android NDK提供了脚本来剥离出单独的toolchain,脚本的名字叫make-standalone-toolchain.sh




1. 下载Android NDK


http://developer.android.com/sdk/ndk/index.html


我用的是android-ndk-r6b




2. 提取toolchain




可以参考文档docs/STANDALONE-TOOLCHAIN.html


在linux系统中解压NDK,假设解压到/opt;


cd /opt/android-ndk-r6b/


build/tools/make-standalone-toolchain.sh --platform=android-8


expr: warning: unportable BRE: `^\\([^\\-].*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\(--[^=]*\\)=.*$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^--[^=]*=\\(.*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
Auto-config: --toolchain=arm-linux-androideabi-4.4.3
Copying prebuilt binaries...
Copying sysroot headers and libraries...
Copying libstdc++ headers and libraries...
expr: warning: unportable BRE: `^\\([^\\-].*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\(--[^=]*\\)=.*$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\(--.*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\([^\\-].*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\([^\\-].*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\([^\\-].*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^\\(--[^=]*\\)=.*$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
expr: warning: unportable BRE: `^--[^=]*=\\(.*\\)$': using `^' as the first character
of the basic regular expression is not portable; it is being ignored
Creating package file: /tmp/ndk-hansel/arm-linux-androideabi-4.4.3.tar.bz2
Cleaning up...
Done.




有一些警告没有关系,最终得到的是一个压缩包 /tmp/ndk-hansel/arm-linux-androideabi-4.4.3.tar.bz2


注意:这个是我的Linux机器上的目录。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇自己重写Android下的拥有拖拽功能.. 下一篇Android中activity向service中传值

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)