"Go" Android underlying libraries and programs

Source: Internet
Author: User

Original URL: http://blog.csdn.net/louiswangbing/article/details/6616202

Android underlying libraries and programs

1, the basic structure of the local implementation

The native implementation level of Android has basic libraries and programs that are fundamental to the operation of the Android base system, which mainly includes the following:

L standard C + + library bionic;

L C language Tool library libcutils;

L INIT process;

l Shell tools;

L C + + tool library Libutils.

2. Ways to add local libraries

Adding a local library or program to the Android, regardless of its code path, is only relevant to their android.mk file.

Android.mk and ordinary makefile slightly different, with a unified writing, mainly including some of the system public macro definition.

The ANDROID.MK options refer to the following file paths:

Build/core/config.mk

The default values for each option are defined in the following file:

Build/core/base_rules.mk

You can also generate multiple executable programs, dynamic libraries, or static libraries in one android.mk.

The template for compiling an executable program in Android is as follows:

# Test EXE

Local_path: =$ (call My-dir)

Include $ (clear_vars)

local_src_files:= \

Main.c

Local_module: =test_exe

#LOCAL_C_INCLUDES: =

#LOCAL_STATIC_LIBRARIES: =

# local_shared_libraries:=

Include $ (build_executable)

Compile an executable program that needs to be local_src_files in the source file path (quite the same as the current directory), in Local_c_includes join the header file path that you need to include in the LOCAL_STATIC_ Add the name of the static library (. A) that you want to connect to in libraries, and the name of the dynamic library (. So) that you want to connect to in Local_shared_libraries. Local_module represents the final name of the module. Finally, the use of the include $ (build_executable) means that the compilation is done as an executable program. In this example local_module is defined as Test_exe, so the name of the resulting executable program is test_exe.

The template for compiling a static library in Android.mk is as follows:

# test Staticlib

Local_path: =$ (call My-dir)

Include $ (clear_vars)

local_src_files:= \

Main.c

Local_module: =libtest_static

#LOCAL_C_INCLUDES: =

#LOCAL_STATIC_LIBRARIES: =

# local_shared_libraries:=

Include $ (build_static_library)

Compiling a static library, the basic content is similar to the compiled executable, except that using the include $ (build_static_library) means compiling the static library, in this case local_module is defined as libtest_static, So the name of the final generated static library is LIBTEST_STATIC.A.

The template for compiling a dynamic library in Android.mk is as follows:

# test Sharedlib

Local_path: =$ (call My-dir)

Include $ (clear_vars)

local_src_files:= \

Main.c

Local_module: =libtest_shared

target_prelink_module:= false

#LOCAL_C_INCLUDES: =

#LOCAL_STATIC_LIBRARIES: =

# local_shared_libraries:=

Include $ (build_shared_library)

Compiling a dynamic library, the basic content and the compiler executable, the static library is similar, the difference is to use the include $ (build_ SHARED _library) to represent the compiled static library, in this case local_module is defined as Libtest_ SHARED, So the name of the final generated static library is libtest_shared.so.

There is no need to differentiate C source files and C + + source files in Android, and join Local_src_files in unity.

The compiled results for executable, static, and dynamic libraries are in the following directory:

Out/target/product/generic/obj/executable

Out/target/product/generic/obj/static_library

Out/target/product/generic/obj/shared_library

The Magic table folders for each module are:

L Executable Program: {xxx}_intermediates

L Static Library: {Xxx}_static_intermediates

L Dynamic Library: {xxx}_shared_intermediates

where {XXX} is the name defined by Local_module in each module.

During compilation, the target and content can be compiled, and the contents of the host can be compiled. The above example is the content of the compilation target, executable program, dynamic library, static library using macros are:

Include $ (build_executable)

Include $ (build_shared_library)

Include $ (build_static_library)

The contents of the compiled host, executable programs, dynamic libraries, static libraries using macros are:

Include $ (build_host_executable)

Include $ (build_host_shared_library)

Include $ (build_host_static_library)

"Go" Android underlying libraries and programs

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.