ndk-build instructions

ndk-build Scripts can be compiled for the use of project-based Make the NDK build system. In addition, we are also against  ndk-build the use of  Android.mk and  Application.mk  provide a more specific document configuration.

Internal Compiler

Run  ndk-build the script is equivalent to running the following command:

    $GNUMAKE -f <ndk>/build/core/build-local.mk
    <parameters>
    
 

$GNUMAKE Point GNU Make version 3.81 or higher, <ndk> the point NDK installation directory. You can call ndk-build according to the information from the other shell scripts (or even your own Make file).

Calls from the command line

ndk-build NDK installation scripts are located in the top-level directory. To run the script from the command line, please call in your application directory or subdirectories. E.g:

    $ cd <project>
    $ <ndk>/ndk-build
    
 

In this example, <project> the root directory to the project, and <ndk> then you install the NDK directory.

 

Options

ndk-build all the parameters are passed directly to the NDK build scripts to run the underlying GNU  make command. Please  ndk-build and Form  ndk-build <option> options in combination. E.g:

    $ ndk-build clean
    
 

You can use the following options:

clean
Remove all binary files generated before.

Note : On Mac OS X, run  ndk-build clean time if a large number of parallel execution , may cause a compilation error message contains the following:

    rm: fts_read: No such file or directory
    
 

To avoid this problem, consider not using   modifier, or to   choose a smaller value (eg 2).-jNN

V=1
Start to compile and display the compile command.
-B
Enforce a complete recompilation.
-B V=1
Enforce a complete recompilation, compile and display command.
NDK_LOG=1
NDK show the internal log messages (for debugging itself NDK).
NDK_DEBUG=1
Enforce compile a checked (see Table 1 ).
NDK_DEBUG=0
Release enforced compiled (see Table 1 ).
NDK_HOST_32BIT=1
Always use the tool chain in 32-bit mode (see  64-bit and 32-bit tools chain ).
NDK_APPLICATION_MK=<file>
Use  NDK_APPLICATION_MK  variable to point to a particular  Application.mk  file to be compiled.
-C <project>
Compile located in  <project>  native code project path. If you do not want to end by  cd  switching to the path, this option is useful.

 

You can debug version of the compiler to compile and release

Use  NDK_DEBUG option and under certain circumstances by  AndroidManifest.xml the specified debug or release version of the compiler, optimization-related behavior and whether to include symbols. Table 1 shows the results for each set of possible combinations.

Table 1. NDK_DEBUG (command line) and  android:debuggableresults (list) portfolio.

List settings NDK_DEBUG = 0 NDK_DEBUG = 1 NDK_DEBUG not specified
android:debuggable="true" Commissioning; symbol; Optimized * 1 Commissioning; symbol; unoptimized * 2 (The same NDK_DEBUG = 1)
android:debuggable="false" Publishing; symbol; Optimized Publishing; symbol; unoptimized Publishing; unsigned; optimized * 3

* 1: for analysis.
* 2: used to run the  ndk-gdb default value.
* 3: Default mode.

Note : NDK_DEBUG=0 the equivalent  APP_OPTIM=release, and a  -O2 compiler. NDK_DEBUG=1 The equivalent  Application.mk of  APP_OPTIM=debug, and with the  -O0 compilation. For more information  APP_OPTIM, please see  Application.mk .

 

For example, the command line syntax is:

    $ NDK-build NDK_DEBUG = 1
    
 

64-bit and 32-bit tools chain

Some tools simultaneously comes chain and 32-bit 64-bit version. For example, a directory  <ndk>/toolchain/<name>/prebuilt/ , and  <ndk>/prebuilt/may contain both  linux-x86 and  linux-x86_64 folders, respectively for the lower tool 32 Linux and 64-bit mode. ndk-build script will automatically select the 64-bit version of the tool chain (if the host operating system supports it). You can be in your own environment or ndk-build command line using the  NDK_HOST_32BIT=1 mandatory use of 32-bit tool chain.

Note that, the tool 64 can make better use of host resources (e.g., they are faster and can handle larger programs), while they can still generate 32-bit binary Android.

Claim

Typically, you need to install the GNU Make version 3.81 or later to use ndk-build or NDK. Compile the script will detect noncompliance Make tool, and generates an error message.

If you have GNU Make 3.81 installed, but the default  make command does not start it, define your environment  GNUMAKEto point to it before starting ndk-build. E.g:

    $ export GNUMAKE=/usr/local/bin/gmake
    $ ndk-build
    
 

You can be  $NDK/prebuilt/<OS>/bin/ the other host pre-compiler tool environment variable is replaced with the following:

    $ export NDK_HOST_AWK=<path-to-awk>
    $ export NDK_HOST_ECHO=<path-to-echo>
    $ export NDK_HOST_CMP=<path-to-cmp>
    

Guess you like

Origin www.cnblogs.com/gamesky/p/11369142.html