Android.mk add common templates for local programs and libraries

Source: Internet
Author: User

android.mk add common templates for local programs and libraries


Android add local programs or libraries, which are not related to the path they are located in, only with their configuration files android.mk about. the android.mk file can contain some of the system's public macros. Multiple executable programs, dynamic libraries, or static libraries can be generated in a single android.mk.

A, compilingC + +Templates for Applications

    #Demo Exe     Local_path: = $ (call My-dir)     #include $ (clear_vars)     local_src_files:= main.c     local_module: = Demo_exe     #LOCAL_C_INCLUDES: =     #LOCAL_STATIC_LIBRARIES: =     #LOCAL_SHARED_LIBRARIES: =     include $ (build_executable)


(Explanation: := is the meaning of the assignment, += is the added meaning, $ is a value that refers to a variable) build_executable represents the compilation as an executable program.

Additional notes:

include$ (build_package) is to compile a apk ,

include$ (build_static_java_library) is to compile the Jar package.

B, compile the template for the static library

     #Demo Static Lib     Local_path: = $ (call My-dir)     include $ (clear_vars)     local_src_files:=/              HELLOWORLD.C     local_module:= libdemo_static     #LOCAL_C_INCLUDES: =     #LOCAL_STATIC_LIBRARIES: =     #LOCAL_SHARED_ LIBRARIES: =     include $ (build_static_library)

the general and the above are similar, build_static_library represents compiling a static library . A file. Static libraries are not copied to the APK package, but can be used to compile shared libraries.

C, compiling templates for dynamic libraries

    #Demo Shared Lib     Local_path: = $ (call My-dir)     include $ (clear_vars)     local_src_files:=/              HELLOWORLD.C     local_module:= libdemo_shared     Target_prelink_modules: = False     #LOCAL_C_INCLUDES: =     #LOCAL_STATIC_LIBRARIES: =     #LOCAL_SHARED_ LIBRARIES: =      include$ (build_shared_library)



the general and the above are similar, build_shared_library represents the compilation of a dynamic library.

The results of the above three are as follows,generic depending on the target will change:

Out/target/product/generic/obj/executable

Out/target/product/generic/obj/static_library

Out/target/product/generic/obj/shared_library


The target folders for each module are:


executable Program: xxx_intermediates

Static libraries: xxx_static_intermediates

Dynamic Libraries: xxx_shared_intermediates

in the android.mk file, you can also specify the final target installation path, using the Local_module_path and the Local_unstripped_path to specify. Different file system paths are selected with the following macros:

Target_root_out: Represents the root file system out/target/product/generic/root. Target_out: Represents the system filesystem out/target/product/generic/system. Target_out_data: Represents the DATA file system out/target/product/generic/data. Out_dir: Code Engineering compile-Time Out build directory product_out: Image generation Directory


The usage examples are as follows:

Local_module_path: =$ (target_root_out)

Android.mk add common templates for local programs and libraries

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.