Android.mk adding native programs and libraries to frequently used templates

Source: Internet
Author: User

android.mk add frequently used templates for local programs and libraries


Android Add the local program or library. These programs and libraries are not related to the path they are located in. is only relevant to their profile android.mk . android.mk files can mainly include some system public macros. You can build multiple running programs, dynamic libraries, or static libraries 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 compiling in a way that can run a program.

Additional notes:

include$ (build_package) is to compile a apk ,

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

B. Compiling a template for a 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 in the following, for example,generic will change according to the detailed target :

Out/target/product/generic/obj/executable

Out/target/product/generic/obj/static_library

Out/target/product/generic/obj/shared_library


The target directory for each module is:


to run the 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, Local_module_path and the Local_unstripped_path to specify. Different file system paths are selected using the following macro:

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 Project compile-Time Out build folder product_out: Image Generation Folder



Use the method to scale as follows:

Local_module_path: =$ (target_root_out)

Android.mk adding native programs and libraries to frequently used templates

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.