【Android】NDK的使用常见问题

本文介绍了Android NDK的使用,包括如何生成设备专用的toolchain,以及解决在编译过程中遇到的'only position independent executables (PIE) are supported.'错误。通过执行特定命令生成toolchain,并设置环境变量后,可以开始进行交叉编译。当遇到PIE错误时,可以在编译选项中添加相应参数来解决。
摘要由CSDN通过智能技术生成

Android提供了NDK工具用以编译能够Android设备上运行的C/C++程序,本质上就是交叉编译,下面给出几篇关于NDK相关的文章。

教程

生成设备专用的toolchain

${NDKROOT}/build/tools 下有两个脚本:make_standalone_toolchain.py 和 make-standalone-toolchain.sh,这两个脚本的功能相似,下面是脚本的使用方式(–help):

usage: make_standalone_toolchain.py [-h] --arch
                                    {arm,arm64,mips,mips64,x86,x86_64}
                                    [--api API]
                                    [--stl {gnustl,libc++,stlport}]
                                    [--unified-headers] [--force] [-v]
                                    [--package-dir PACKAGE_DIR | --install-dir INSTALL_DIR]

Creates a toolchain installation for a given Android target. The output of
this tool is a more typical cross-compiling toolchain. It is indended to be
used with existing build systems such as autotools.

optional arguments:
  -h, --hel
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值