android.mk 包含boost,Boost-for-Android

Boost for Android badge.svg

Boost for android is a set of tools to compile the main part of the Boost C++ Libraries for the Android platform.

Currently supported boost versions are 1.45.0, 1.48.0, 1.49.0, 1.53.0, 1.54.0, 1.55.0, 1.65.1, 1.66.0, 1.67.0, 1.68.0, 1.69.0, 1.70.0, 1.71.0, 1.73.0 and 1.74.0.

x86, mips, and 64-bit architectures are built with Boost 1.65.1 and NDK r16-beta2, this version uses clang toolchain with llvm libc++ STL library.

Other versions of Boost are built only for arm architecture, they are using gcc toolchain and gnustl library.

To compile Boost for Android you may use one of the following NDKs:

For NDK from r4 to r10, GCC with gnustl_static runtime library is used, only ARM architecture is supported.

For NDK from r16 to r18b, clang with c++_static runtime library is used, all architectures are supported.

For NDK from r19 and up, clang with c++_shared runtime library is used, all architectures are supported.

Quick Start

Dependencies

GNU Make

autoconf, automake, libtool, pkg-config

Usage

Compiling

Linux.

./build-android.sh $(NDK_ROOT)

Windows:

build-android.bat $(NDK_ROOT)

NOTE: Do not forget to replace backslash with slashes in $(NDK_ROOT). For example set $(NDK_ROOT) to D:/android-ndk-r8e instead of D:\android-ndk-r8e

On windows you will need MSYS to be able to launch the corresponding bat files (http://www.mingw.org/wiki/MSYS).

This command will download and build boost against the NDK specified and output the final headers and libs in the build folder. Make sure to provide an absolute path the the NDK folder!

For more info about usage and available commands use --help.

Including

Now that you got Boost compiled you must add it to your Android.mk file. Locate the build folder and copy the include and lib folders over to your project's jni folder. A recommended path inside your project is /jni/boost/.

Add the following to your Android.mk (note that here we're using Boost 1.48 and have assumed that Boost resides inside /jni/boost):

LOCAL_CFLAGS += -I$(LOCAL_PATH)/boost/include/boost-1_48

LOCAL_LDLIBS += -L$(LOCAL_PATH)/boost/lib/ -lboost_system -lboost_...

LOCAL_CPPFLAGS += -fexceptions

LOCAL_CPPFLAGS += -frtti

Now use ndk-build to build and have fun with it!

Note that you should build your project and Boost with the same version of NDK as the C++ STL inside NDK r4 and NDK r5 are not compatible in some subtle details.

Contribute

The projects is split into two main branches, the master and devel. The master branch is where the current stable version lies and which should be used in most of the cases, the devel branch in turn is where development occurs. To contribute to the project make sure to use the devel branch which will make it easier to test changes and to merge incoming pull requests (PR).

Troubleshooting

In case you encounter bunch of linker errors when building your app with boost,

this might help:

Building from a 64 bit machine (Linux)

Make sure you have installed the 32 bit libraries. Those are required to be able

to use the NDK.

To install them just use the following

$ sudo apt-get install ia32-libs

NDK 7 (CrystaX)

Add -lgnustl_static AFTER all boost libraries to the LOCAL_LDLIBS line in

Android.mk. Example:

LOCAL_LDLIBS += lboost_system-gcc-md lboost_thread-gcc-md -lgnustl_static

NDK 8 (official)

Do everything that is in the NDK 7 Crystax section, but also

add full path to the gnustl_static library to the link paths. Example:

LOCAL_LDLIBS += lboost_system-gcc-md lboost_thread-gcc-md \

-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \

-lgnustl_static

NDK 17 (official)

Support for ARMv5 (armeabi), MIPS, and MIPS64 has been removed. Attempting to build any of these ABIs will result in an error.

This project will exclude these architectures for compiling with NDK 17.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这些都是 Android NDK 内部的 `Android.mk` 文件。其中,`./android-ndk-r25c/sources/android/native_app_glue/Android.mk` 是用于编译 Native Activity 示例应用程序的 `Android.mk` 文件;`./android-ndk-r25c/sources/android/support/Android.mk` 是包含一些 Android 支持库的 `Android.mk` 文件;`./android-ndk-r25c/sources/android/ndk_helper/Android.mk` 是包含一些辅助函数和类的 `Android.mk` 文件;`./android-ndk-r25c/sources/android/cpufeatures/Android.mk` 是用于编译 `cpufeatures` 库的 `Android.mk` 文件,该库提供了一些 CPU 相关的信息和功能;`./android-ndk-r25c/sources/cxx-stl/llvm-libc++abi/Android.mk` 和 `./android-ndk-r25c/sources/cxx-stl/llvm-libc++/Android.mk` 是用于编译 C++ STL 库的 `Android.mk` 文件,分别对应 libc++abi 和 libc++ 两个 STL 库;`./android-ndk-r25c/sources/third_party/googletest/Android.mk` 是用于编译 Google Test 测试框架的 `Android.mk` 文件;`./android-ndk-r25c/sources/third_party/shaderc/Android.mk` 是用于编译 Shaderc 编译器的 `Android.mk` 文件,该编译器可以将 GLSL 代码编译成 SPIR-V 代码;`./android-ndk-r25c/sources/third_party/shaderc/libshaderc/Android.mk` 是用于编译 Shaderc 库的 `Android.mk` 文件;`./android-ndk-r25c/sources/third_party/shaderc/libshaderc_util/Android.mk` 是用于编译 Shaderc Util 库的 `Android.mk` 文件,该库提供了一些辅助函数和类;`./android-ndk-r25c/sources/third_party/shaderc/third_party/Android.mk` 是用于编译 Shaderc 编译器依赖的第三方库的 `Android.mk` 文件,包括 glslang 和 spirv-tools 两个库;`./android-ndk-r25c/sources/third_party/shaderc/third_party/glslang/Android.mk` 是用于编译 glslang 库的 `Android.mk` 文件;`./android-ndk-r25c/sources/third_party/shaderc/third_party/spirv-tools/Android.mk` 是用于编译 spirv-tools 库的 `Android.mk` 文件;`./android-ndk-r25c/sources/third_party/vulkan/src/build-android/jni/Android.mk` 是用于编译 Vulkan 库的 `Android.mk` 文件。 如果您要在 Android NDK 中编写自己的 `Android.mk` 文件,可以参考这些示例文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值