android-cmake 配置

来源:互联网 发布:php 实现微信网页授权 编辑:程序博客网 时间:2024/04/29 16:16

改编自 http://android-cmake.googlecode.com/hg/documentation.html


Android CMake Installation

This file gives instructions on how to properly setup your NDK for cmake.

Requirements

* android ndk r5b * android sdk * ant -- for command line build of android projectsThese instructions will work on Linux, but may work on Mac OSX or Windows with slight modification.android-ndk-r5b can be found here:http://developer.android.com/sdk/ndk/index.htmlRead its documentation, specifically the Standalone Toolchain.Assumming you read the documentation, follow steps for creating a standalonetoolchain. export NDK=~/android-ndk-r5b $NDK/build/tools/make-standalone-toolchain.sh --platform=android-5 \ --install-dir=$HOME/android-toolchain//notes:对于4.0,--platform=android-14android-sdk can be found here:http://developer.android.com/sdk/index.htmlPlease install that, and add it to your path. ANDROID_SDK=~/android-sdk-linux_86 export PATH=$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$PATHLets try the hello-cmake sample.

Ubuntu Quick Start

Lets assume you have ANDROID_CMAKE pointing to the android-cmake directory.Export a working directory, this will be where the script downloads the ndk to WORK=$HOME(如果没有,执行如下命令下载 hg clone https://code.google.com/p/android-cmake/ $HOME/android/android-cmake)
This will pull down the ndk r5, and setup a NDK standalone toolchain:  cd $ANDROID_CMAKE/scripts  ./get_ndk_toolchain_linux.sh $WORK//对于其他版本android,需要修改get_ndk_toolchain_linux.sh。例如其中的ndk包的名称。对于4.0,为ball=android-ndk-r7b-linux-x86.tar.bz2//ln -fs $destination/android-toolchain /opt/android-toolchain,一定要成功,否者可能出问题
Add the toolchain location to your bashrc or otherwise export it to your env:  echo export ANDTOOLCHAIN=$ANDROID_CMAKE/toolchain/android.toolchain.cmake >> $HOME/.bashrcNow when you re-source your bashrc, you can run cmake with the toolchain:  cd $MY_CMAKE_PROJECT  mkdir build  cd build  cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN ..

alias trick

Add these lines to your bashrc: export ANDTOOLCHAIN=$ANDROID_CMAKE/toolchain/android.toolchain.cmake alias android-cmake='cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN 'Then to run cmake for android do: cd $MY_CMAKE_PROJECT mkdir build cd build android-cmake ..

0 0
原创粉丝点击