`
7090
  • 浏览: 273405 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

(装)NDK Build 参数

 
阅读更多
'ndk-build' Overview

ndk-build概述

I. Usage:

一、使用方法:

The Android NDK r4 introduced a new tiny shell script, named 'ndk-build', to simplify building machine code.

Android NDK r4引入一个新的小型shell脚本,名字是ndk-build,以简化机器码的构建。

The script is located at the top-level directory of the NDK, and shall be invoked from the command-line when in your application project directory, or any of its sub-directories. For example:

脚本位于NDK的顶级目录,并且将在你的应用程序工程目录,或它的任意子目录中的命令行调用。例如:

    cd $PROJECT

    $NDK/ndk-build

Where $NDK points to your NDK installation path. You can also create an alias or add $NDK to your PATH to avoid typing it every time.

这里$NDK指向你的NDK安装目录。你还可以创建一个别名或者添加$NDK到你的PATH环境变量以避免每次都键入它(注:PATH区分大小写)。

II. Options:

二、选项:

All parameters to 'ndk-build' are passed directly to the underlying GNU Make command that runs the NDK build scripts. Notable uses include:

所有给ndk-build的参数被直接传递到运行NDK构建脚本的底层GNU Make命令。值得注意的使用方法包括:

  ndk-build                  --> rebuild required machine code.                                             ndk-build                  --> 重新构建所需的机器代码。

ndk-build clean            --> clean all generated binaries.                                              ndk-build clean            --> 清除所有生成的二进制文件。

  ndk-build NDK_DEBUG=1      --> generate debuggable native code.                     ndk-build NDK_DEBUG=1      --> 生产可调试的本地代码。

ndk-build V=1              --> launch build, displaying build commands.                      ndk-build V=1              --> 启动构建,显示构建命令。

ndk-build -B               --> force a complete rebuild.                                                     ndk-build -B               --> 强制完全重新构建。

ndk-build -B V=1           --> force a complete rebuild and display build commands.    ndk-build -B V=1           --> 强制完全重新构建并且显示构建命令。

ndk-build NDK_LOG=1        --> display internal NDK log messages (used for debugging the NDK itself).    ndk-build NDK_LOG=1        --> 显示内部NDK日志消息(用于调试NDK自身)。

ndk-build NDK_DEBUG=1      --> force a debuggable build (see below)           ndk-build NDK_DEBUG=1      --> 强制调试版构建(见下)(注:调试版指带调试信息,可以用gdb调试的二进制文件)

ndk-build NDK_DEBUG=0      --> force a release build (see below)                   ndk-build NDK_DEBUG=0      --> 强制发布版构建(见下)(注:发布版指不带调试信息的二进制文件)



ndk-build NDK_APP_APPLICATION_MK=<file> --> rebuild, using a specific Application.mk pointed to by the NDK_APP_APPLICATION_MK command-line variable.

ndk-build NDK_APP_APPLICATION_MK=<文件名> --> 重新构建,通过NDK_APP_APPLICATION_MK命令行变量指向使用特定的Application.mk.



ndk-build -C <project>     --> build the native code for the project path located at <project>. Useful if you don't want to 'cd' to it in your terminal.

ndk-build -C <工程目录>     --> 构建位于<工程目录>的工程的本地代码。当你不想在终端上用cd切换到那个目录时有用。



III. Debuggable versus Release builds:



三、调试版和发布版构建:

--------------------------------------



In NDK r5, ndk-build has been modified to make it easier to switch between release and debug builds. This is done by using the NDK_DEBUG variable.



在NDK r5,ndk-build已经被修改成可以更容易地在发布版和调试版构建之间切换。通过使用NDK_DEBUG变量来做到。



For example:



例如:



$NDK/ndk-build NDK_DEBUG=1  => forces the generation of debug binaries

$NDK/ndk-build NDK_DEBUG=1  => 强制生成调试版二进制文件。



$NDK/ndk-build NDK_DEBUG=0  => forces the generation of release binaries

$NDK/ndk-build NDK_DEBUG=0  => 强制生成发布版二进制文件。



If you don't specify NDK_DEBUG, ndk-build will keep its default behaviour, which is to inspect the AndroidManifest.xml, if any, and see if its <application> element has android:debuggable="true".

如果你不指定NDK_DEBUG,ndk-build将保持它的默认行为,即检查AndroidManifest.xml,如果有,检查它的<application>元素是否有android:debuggable="true"属性。



IMPORTANT: If you use the build tools of SDK r8 (or higher), you won't need to touch your AndroidManifest.xml file at all!

重要事项:如果你使用SDK r8(或更高)的构建工具,你将完全不必修改你的AndroidManifest.xml文件!



That's because if you build a debug package (e.g. with "ant debug" or the corresponding option of the ADT plugin), the tool will  automatically pick the native debug files generated with NDK_DEBUG=1.

那是因为如果你构建一个调试包(例如,使用“ant debug”或ADT插件相应选项),工具将自动选择用NDK_DEBUG=1生成原生调试版文件。(注:也就是说,Java代码为调试版,则JNI的C代码也自动切换为调试版)



Also, as a convenience, the release and debug object files generated by the NDK are now stored in different directories (e.g. obj/local/<abi>/objs and obj/local/<abi>/objs-debug). This avoids having to recompile all your sources when you switch between these two modes (even when you only modified one or two source files).

同样,方便起见,有NDK生成的发布版和调试版对象文件现在被存放在不同的目录中(例如obj/local/<abi>/objs和obj/local/<abi>/objs-debug)。(注:abi是应用二进制接口的缩写,这里指代某类交叉编译器,例如EABI,嵌入式应用二进制接口)。这避免当你在这两种模式之间切换时必须重新编译所有源代码(即便你仅仅修改一个或两个源文件)。(注:Makefile的策略导致,Makefile认为xxx.c一般只会生成xxx.o,也就是说调试版和发布版的.o不能共存,上面的方法类似Windows,使用不同的目录输出不同版本的.o,以避免覆盖)


IV. Requirements:

四、要求:


You need GNU Make 3.81 or later to use 'ndk-build' or the NDK in general. The build scripts will detect that you're using a non-compliant Make tool and will complain with an error message.

一般你需要GNU Make 3.81或更高以使用ndk-build或NDK(注:因为GNU的make有两种)。构建脚本将检测到你正在使用不兼容的Make工具并且用一个错误消息解释。



If you have GNU Make 3.81 installed, but that it is not launched by the default 'make' command, define GNUMAKE in your environment to point to it before launching 'ndk-build'. For example:

如果你已经安装GNU Make 3.81以上,但不能用默认的make命令启动,可以在运行ndk-build之前在你的环境变量中定义GNUMAKE指向它的路径。例如:



   GNUMAKE=/usr/local/bin/gmake ndk-build (注:环境变量的键值对出现在命令之前,常用于临时变更环境变量,等效于下面的export命令)

Or to make the change more permanent:

或更永久地改变:



export GNUMAKE=/usr/local/bin/gmake

ndk-build



Adapt to your shell and GNU Make 3.81 installation location.

请适配你的shell和GNU Make 3.81的安装位置。



V. Internals:

五、内幕:

'ndk-build' itself is a tiny wrapper around GNU Make, its purpose is simply to invoke the right NDK build script, it is equivalent to;

ndk-build本身是对GNU Make的一个小型封装,它的目的是简化正确NDK构建脚本调用,它等效于:



$GNUMAKE -f $NDK/build/core/build-local.mk [parameters]

Where '$GNUMAKE' points to GNU Make 3.81 or later, and $NDK points to your NDK installation directory.

这里$GNUMAKE指向GNU Make 3.81或更新,而$NDK指向你的NDK安装目录。



Use this knowledge if you want to invoke the NDK build script from other shell scripts (or even your own Makefiles).

如果你想从其它shell脚本中调用NDK构建脚本(或者甚至是你自己的Makefile文件)(注:Makefile是make的默认配置文件,类似于Ant的build.xml)时可以使用这种技巧。

原文:http://blog.csdn.net/hgl868/article/details/6724276
分享到:
评论

相关推荐

    ndk-build.zip

    Windows下使用git bash通过配置该ndk-build可以实现在git bash中执行ndk-build功能

    ndk-build-examples

    ndk-build example. adb run executable. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ndk-build.exe

    通过ndk-build.exe转接,可以直接在git bash中使用ndk-build功能。配合cmder使用git bash可以做到类似Linux的体验

    incredibuild_ndk-build.rar

    下载完的ndk-build.cmd和profile.xml覆盖到NDK目录(如E:\android\android-ndk-r10e)下,记得原有的ndk-build要备份一下。

    jni使用ndk-build的方式调用

    jni调用 使用传统的ndk-build方式 见博客http://blog.csdn.net/findsafety/article/details/72311321

    android studio ndk-build 编译C生成.so文件demo

    android studio ndk-build 编译C生成.so文件, 要把代码中加密的部分打包成so文件,

    ndk-build编译工具

    ndk-build Native方法编译工具

    ndk build mk文件

    ndk直接编译cpp code需要的mk文件,包括Android.mk和Application.mk两个文 件,看里面备注来决定编译bin还是so

    ndk-build编译so文件

    在Ubuntu的情况下,ndk-build编译C++成Android Studio可用的so文件。这里是一个将android-ndk-r21e生成交叉编译链之后,可以直接使用ndk-build这个指令就可以生成Android Studio可以使用的依赖库.so文件。CRC16是一...

    NDK开发传递对象作为参数

    NDK开发有时需要Java和C/C++把对象作为参数互相传递, 详情参考: C/C++传递对象到Java:https://blog.csdn.net/niuba123456/article/details/80994037 Java传递对象到C/C+:...

    ndk-build.cmd

    ndk-build.cmd

    android-gpuimage-ndkbuild-sample:使用 android-gpuimage 的 Android NDK 构建示例

    android-gpuimage-ndkbuild-sample 使用基于 Android Studio 的 android-gpuimage 库的 Android NDK 构建示例 你应该看到 android-gpuimage 和 iOS GPUImage 框架 未来 我将比较 noen 和 android-gpuimage 库。

    Android ndk Android.mk

    这个虽然只是个简单的jnidemo、但是涵盖了Android.mk 和Application.mk 的原理 重点是Android NDK编译的理解 mac 系统下 切换到jni目录,然后呢个 ndk-build

    MASTERING_ANDROID_NDK

    掌握 Android NDK构建系统 - 第1部分:使用ndk-build的技术 本文不是“Hello world!” - NDK的类型教程。虽然我仍然会快速介绍ndk-build的基本知识,但它不是本文的重点。相反,我将总结一些非常有用的NDK技术和我...

    NDK Camera

    # NDK Camera [![Build Status](https://travis-ci.org/luncliff/NdkCamera.svg?branch=master)](https://travis-ci.org/luncliff/NdkCamera) &gt; If there is an issue with this library, please mail to luncliff...

    ndk-r17b编译及使用ollvm-tti步骤(提供编译后文件)

    9.复制build文件夹中的bin、和lib以及lib64 到NDK_PATH/toolchains/llvm/prebuilt/windows-x86_64/目录下 三、使用 10.在Android.mk中加入以下就能使用混淆功能了 LOCAL_CFLAGS := -mllvm -sub -mllvm -bcf -...

    android ndk,双libs打包实例

    android ndk,双libs打包实例

    Android 使用ndk-build和cmake构建JNI程序 demo

    Android 使用ndk-build和cmake构建JNI程序 demo

    Android SDK NDK API 对应关系

    Android SDK NDK API 对应关系

    ndk c6455 dsp ndk c6455

    ti dsp ndk c6455ti dsp ndk c6455 ti dsp ndk c6455 ti dsp ndk c6455 ti dsp ndk c6455

Global site tag (gtag.js) - Google Analytics