原创 2012年03月30日 13:57:28




The purpose of Application.mk is to describe which native
'modules' (i.e. static/shared libraries) are needed by your
用来描述你的应用需要哪些native modules
An Application.mk file is usually placed under $PROJECT/jni/Application.mk,
where $PROJECT points to your application's project directory.
Another alternative is to place it under a sub-directory of the top-level
$NDK/apps directory, e.g.:

Where <myapp> is a short name used to describe your 'application'
to the NDK build system (this name doesn't go into your generated
shared libraries or your final packages).
The Application.mk is really a tiny GNU Makefile fragment that must
define a few variables:
    This variable should give the *absolute* path to your
    Application's project root directory. This is used to copy/install
    stripped versions of the generated JNI shared libraries to a
    specific location known to the APK-generating tools.

    Note that it is optional for $PROJECT/jni/Application.mk, but
    *mandatory* for $NDK/apps/<myapp>/Application.mk
    This variable is optional. If not defined, the NDK will build by
    default _all_ the modules declared by your Android.mk, and any
    sub-makefile it may include.

    If APP_MODULES is defined, it must be a space-separated list of module
    names as they appear in the LOCAL_MODULE definitions of Android.mk
    files. Note that the NDK will compute module dependencies automatically.
如果定义了,它是一个以空格分隔的module names的列表,这些names必须定义在Android.mk的LOCAL_MODULE中

    This optional variable can be defined to either 'release' or
    'debug'. This is used to alter the optimization level when
    building your application's modules.
用来选择optimization level,release or debug

    A 'release' mode is the default, and will generate highly
    optimized binaries. The 'debug' mode will generate un-optimized
    binaries which are much easier to debug.

    Note that if your application is debuggable (i.e. if your manifest
    sets the android:debuggable attribute to "true" in its <application>
    tag), the default will be 'debug' instead of 'release'. This can
    be overridden by setting APP_OPTIM to 'release'.

    Note that it is possible to debug both 'release' and 'debug'
    binaries, but the 'release' builds tend to provide less information
    during debugging sessions: some variables are optimized out and
    can't be inspected, code re-ordering can make stepping through
    the code difficult, stack traces may not be reliable, etc...

    A set of C compiler flags passed when compiling any C or C++ source code
    of any of the modules. This can be used to change the build of a given
    module depending on the application that needs it, instead of modifying
    the Android.mk file itself.

    IMPORTANT WARNING: +++++++++++++++++++++++++++++++++++++++++++++++++++
    + All paths in these flags should be relative to the top-level NDK
    + directory. For example, if you have the following setup:
    +    sources/foo/Android.mk
    +    sources/bar/Android.mk
    +  To specify in foo/Android.mk that you want to add the path to the
    + 'bar' sources during compilation, you should use:
    +   APP_CFLAGS += -Isources/bar
    + Or alternatively:
    +   APP_CFLAGS += -I$(LOCAL_PATH)/../bar
    + Using '-I../bar' will *NOT* work since it will be equivalent to
    + '-I$NDK_ROOT/../bar' instead.

    NOTE: In android-ndk-1.5_r1, this only applied to C sources, not C++ ones.
          This has been corrected to match the full Android build system.

    An alias for APP_CPPFLAGS, to be considered obsolete as it may disappear
    in a future release of the NDK.

    A set of C++ compiler flags passed when building C++ sources *only*.

    NOTE: In android-ndk-1.5_r1, this applied to both C and C++ sources.
          This has been corrected to match the full Android build system.
          You can now use APP_CFLAGS for flags that shall apply to C and
          C++ sources.

    By default, the NDK build system will look for a file named Android.mk
    under $(APP_PROJECT_PATH)/jni, i.e. for the file:


    If you want to override this behaviour, you can define APP_BUILD_SCRIPT
    to point to an alternate build script. A non-absolute path will always
    be interpreted as relative to the NDK's top-level directory.

    By default, the NDK build system will generate machine code for the
    'armeabi' ABI. This corresponds to an ARMv5TE based CPU with software
    floating point operations. You can use APP_ABI to select a different

    For example, to support hardware FPU instructions on ARMv7 based devices,

        APP_ABI := armeabi-v7a

    Or to support the IA-32 instruction set, use:

        APP_ABI := x86

    Or to support all three at the same time, use:

        APP_ABI := armeabi armeabi-v7a x86

    Or even better, since NDK r7, you can also use the special value
    'all' which means "all ABIs supported by this NDK release":

        APP_ABI := all

    For the list of all supported ABIs and details about their usage and
    limitations, please read docs/CPU-ARCH-ABIS.html

    By default, the NDK build system provides C++ headers for the minimal
    C++ runtime library (/system/lib/libstdc++.so) provided by the Android

    However, the NDK comes with alternative C++ implementations that you can
    use or link to in your own applications. Define APP_STL to select one of
    them. Examples are:

       APP_STL := stlport_static    --> static STLport library
       APP_STL := stlport_shared    --> shared STLport library
       APP_STL := system            --> default C++ runtime library

    For more information on the subject, please read docs/CPLUSPLUS-SUPPORT.html

    In prior NDK versions, the simple fact of using the GNU libstdc++
    runtime (i.e. by setting APP_STL to either 'gnustl_static' or
    'gnustl_shared') enforced the support for exceptions and RTTI in all
    generated machine code. This could be problematic in specific, but rare,
    cases, and also generated un-necessarily bigger code for projects that
    don't require these features.

    This bug was fixed in NDK r7b, but this means that if your code requires
    exceptions or RTTI, it should now explicitely say so, either in your

    To make it easier to port projects to NDK r7b and later, one can
    optionally defined APP_GNUSTL_CPP_FEATURES to contain one or more of the
    following values:

       exceptions    -> to enforce exceptions support for all modules.
       rtti          -> to enforce rtti support for all modules.

    For example, to get the exact same behaviour than NDK r7:

       APP_GNUSTL_FORCE_CPP_FEATURES := exceptions rtti

    IMPORTANT: This variable is provided here as a convenience to make it
               easier to transition to a newer version of the NDK. It will
               be removed in a future revision. We thus encourage all
               developers to modify the module definitions properly instead
               of relying on it here.

A trivial Application.mk file would be:

-------------- cut here -------------------------
APP_PROJECT_PATH := <path to project>
-------------- cut here -------------------------


android-ndk-r7b\docs\NDK-BUILD.html The Android NDK r4 introduced a new tiny shell script, named ...
  • bjutstar
  • bjutstar
  • 2012年04月05日 16:01
  • 593


android-ndk-r7b\docs OVERVIER.html I. Android NDK Goals: ---------------------The Android VM all...
  • bjutstar
  • bjutstar
  • 2012年03月29日 17:14
  • 735


android-ndk-r7b\docs\CPLUSPLUS-SUPPORT.html Android平台提供了一个minimal C++ runtime support library (/s...
  • bjutstar
  • bjutstar
  • 2012年03月30日 14:18
  • 1119


android-ndk-r7b\docs ANDROID-MK.html 需要首先阅读docs/OVERVIEW.html 本文介绍了Android.mk build file的语法...
  • bjutstar
  • bjutstar
  • 2012年03月29日 17:12
  • 900


android-ndk-r7b\docs\NDK-GDB.html Usage: --------- The Android NDK r4 introduced a helper shell ...
  • bjutstar
  • bjutstar
  • 2012年04月05日 16:22
  • 588

android NDK学习。。。自学总结

电脑配置好NDK环境这里不做介绍,可以搜索下网上。 在android sd中配置idk路径:在工程local.properties文件中加入 ndk.dir=/Users/xurunjie/Doc...
  • jk17640
  • jk17640
  • 2016年08月29日 17:14
  • 447


  • eastmoon502136
  • eastmoon502136
  • 2016年02月28日 17:46
  • 15016

一步一步学习androidNDK编程(hello world)

上一篇博客,已经搭建好了windows下的linux环境(cygwine),这次我们试着写一个hello world。首先需要去android的官网下载android-ndk压缩包,之后解压,进入解压...
  • mockingbirds
  • mockingbirds
  • 2015年04月19日 21:05
  • 3192

Qt入门学习——Qt 5 帮助文档的使用

学习图形界面开发,肯定离不开帮助文档的使用,因为它不像 C 语言那样就那么几个函数接口,图形接口的接口可以用海量来形容,常用的我们可能能记住,其它的真的没有必要去记,用到什么就去帮助文档查看用法。我们...
  • tennysonsky
  • tennysonsky
  • 2015年09月15日 18:50
  • 44922

SQL 帮助文档学习.

  • zzb22848006
  • zzb22848006
  • 2006年02月11日 21:00
  • 3291