Android JNI entry 4-android. mk File Analysis

Source: Internet
Author: User

The android. mk file is a required file for compiling C code using ndk. The Android. mk file describes which c files will be compiled and how to compile them. To understand how to compile Android. mk files, you can master the keywords that will be used in them. Let's take a look at a simple example. This example uses the android ndk

Example of helljni.

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE    := hello-jniLOCAL_SRC_FILES := hello-jni.cinclude $(BUILD_SHARED_LIBRARY)

 

Local_path is the root directory of all c files to be compiled. The value $ (call my-DIR) indicates that the root directory is the directory where Android. mk is located.

 

Include $ (clear_vars) indicates that the global variables used in the compiling environment are cleared when the ndk compilation tool is used, such as local_module and local_src_files, because android may be called multiple times during an ndk compilation process. the global variables used in the MK file may change. I have read the following complex examples for this question and may understand it.

 

Local_module is part of the name when the library is finally generated, and the prefix lib and suffix. So is the name libhello-jni.so of the generated shared library.

 

Local_src_files indicates the name of the C file to be compiled

 

Include $ (build_shared_library) indicates that some shared libraries will be generated during ndk compilation.

 

 

Refer:

 

Makefile (Android. mk) in Android Compiling System

 

Android makefile (Android. mk) analysis (sequence)

 

Android. mk usage and basics

 

<! -- Jiathis button begin -->
<Div id = "ckepop">
<A href = "http://www.jiathis.com/share" class = "jiathis jiathis_txt" target = "_ blank"> </a>
<A class = "jiathis_counter_style_margin: 3px 0 0 2px"> </a>
</Div>
<SCRIPT type = "text/JavaScript" src = "http://v2.jiathis.com/code_mini/jia.js" charset = "UTF-8"> </SCRIPT>
<! -- Jiathis button end --> <! -- Jiathis button begin -->
<Div id = "ckepop">
<A href = "http://www.jiathis.com/share" class = "jiathis jiathis_txt" target = "_ blank"> </a>
<A class = "jiathis_counter_style_margin: 3px 0 0 2px"> </a>
</Div>
<SCRIPT type = "text/JavaScript" src = "http://v2.jiathis.com/code_mini/jia.js" charset = "UTF-8"> </SCRIPT>
<! -- Jiathis button end -->

/**
* @ Author Zhang xingye
* Email: xy-Zhang # 163.com
* Android Development Group: 278401545
*
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.