如何构建Android的C-战神库(NDK) [英] how to build c-ares library in android (NDK)

查看:228
本文介绍了如何构建Android的C-战神库(NDK)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何建立C-顷库的Andr​​oid(NDK的构建)

Can anyone please tell me how to build C-ares library in android (ndk-build)

推荐答案

下面就是如何将它建设成为对ARMv7静态库的<一个href=\"https://speakerdeck.com/deltheil/running-native-$c$c-on-android-number-osdcfr-2012?slide=25\">NDK独立的工具链:

Here's how to build it as a static library for ARMv7 with the NDK standalone toolchain:

export NDK=/tmp/android-ndk-r8b

# Create the standalone toolchain
$NDK/build/tools/make-standalone-toolchain.sh \
--platform=android-9 \
--install-dir=/tmp/my-android-toolchain

export PATH=/tmp/my-android-toolchain/bin:$PATH
export SYSROOT=/tmp/my-android-toolchain/sysroot
export CC="arm-linux-androideabi-gcc --sysroot $SYSROOT"

# Download the latest release
curl -O http://c-ares.haxx.se/download/c-ares-1.9.1.tar.gz
tar xvfz c-ares-1.9.1.tar.gz

# Configure
cd c-ares-1.9.1 && mkdir build
./configure --prefix=$(pwd)/build \
--host=arm-linux-androideabi \
--disable-shared \
CFLAGS="-march=armv7-a"

# Build and install
make && make install

就是这样。静态库是根据部署编译/ lib中/ libcares.a

如果您针对其他archs(如 armeabi 86 )重复配置与适当的 -march 值并重新建立每个拱库。此外,随意:

If you target other archs (e.g. armeabi, x86) repeat the configure with the proper -march value and re-build the library for each arch. Also, feel free to:


  • 调整目标平台,以您的需求(这里的Andr​​oid 2.3,a.k.a API 9级)

  • 使用适合您需要配置选项(例如,您可能要建立另外一个动态库,启用/禁用某些功能,等等)。

  • adapt the target platform to your needs (here Android 2.3, a.k.a API level 9),
  • use the configure options that fit your needs (e.g. you may want to build a dynamic library in addition, enable/disable some features, etc).

这篇关于如何构建Android的C-战神库(NDK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆