JNI code is written, before compiling we have a very important part, is to write the Mk file, the Mk file is equivalent to the GCC compile-time makefile file, it is used to tell the compiler how to compile.
Here only the understanding and common knowledge points to record, want to see all the explanations about ANDROID.MK please visit android.mk.
- The order of execution of the Mk file is executed from the top down order.
- Basic syntax.
$ () reference method or variable
: = Assignment Symbol
+ = Stitching Assignment value
Include introduces (invokes) a code snippet, such as include $ (build_xxxxx), which is equivalent to taking the implementation of the Build_xxxxx method, which is executed when the compiler reads this line.
- The Mk file is basically local_path: = $ (call My-dir) include $ (clear_vars), ending with include $ (build_xxxxx)
- Common reserved variable parsing (basic all starts with Local_)
Local_path: Specifies the location of the current file, which is basically assigned a value of $ (call My-dir)
Local_src_files: Specify the source files to be compiled, multiple files are separated by spaces or using + = stitching to assign values
Local_module: Specifies a MODULE name that must be unique and cannot have spaces
Local_module_filename: Specifies the file name of the generated MODULE, which, by default, is generated by lib<local_module>. A or. so file
Local_static_libraries: referenced static library (. a)
Local_shared_libraries: Referenced dynamic library (. So)
Local_ldflags: Specify Link Flags
- Common system methods
Clear_vars: Clears all preset values
Build_shared_library: Compiling a dynamic library (. So)
Build_static_library: Compiling a static library (. a)
- Compile
CD to the directory where the. mk file is located, execute the ndk-build command in the NDK package
Compilation of the Android JNI