Android. mk adds common templates for local programs and libraries, and android. mk templates

Source: Internet
Author: User

Android. mk adds common templates for local programs and libraries, and android. mk templates

Android. mk adds common templates for local programs and libraries


Add local programs or libraries in Android. These programs and libraries have nothing to do with their paths, but are only related to their configuration file Android. mk. The Android. mk file mainly contains some common macros of the system. Multiple executable programs, dynamic libraries, or static libraries can be generated in an Android. mk file.

A. Compile the C/C ++ application template.

 

    #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)


(Description: = indicates the value assignment, + = indicates the append, and $ indicates the value of a variable.) BUILD_EXECUTABLE indicates compilation in an executable program.

Note:

Include $ (BUILD_PACKAGE) is to compile an apk,

Include $ (BUILD_STATIC_JAVA_LIBRARY) is to compile the jar package.

B. Compile the static library Template

     #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)

In general, BUILD_STATIC_LIBRARY indicates compiling a static library. a file. The static library is not copied to the APK package, but can be used to compile the shared library.

C. Compile the dynamic library Template

 

    #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)



In general, it is similar to the above. BUILD_SHARED_LIBRARY indicates compiling a dynamic library.

The above three generation results are as follows, and the generic changes according to the specific target:

Out/target/product/generic/obj/EXECUTABLE

Out/target/product/generic/obj/STATIC_LIBRARY

Out/target/product/generic/obj/SHARED_LIBRARY


The target folders of each module are:


Executable program: XXX_intermediates

Static Library: XXX_static_intermediates

Dynamic library: XXX_shared_intermediates

 

In the Android. mk file, you can also specify the final target installation path, which is specified using LOCAL_MODULE_PATH and LOCAL_UNSTRIPPED_PATH. Use the following macro to select different file system paths:

TARGET_ROOT_OUT: indicates the root file system out/target/product/generic/root. TARGET_OUT: indicates the system File system out/target/product/generic/system. TARGET_OUT_DATA: indicates the data file system out/target/product/generic/data. OUT_DIR: directory for generating output during code compilation: PRODUCT_OUT: directory for generating Image


Example:

 

LOCAL_MODULE_PATH: = $ (TARGET_ROOT_OUT)


Provide the corresponding library files according to the following Androidmk files and tell me how to compile them into dynamic library files,

Too advanced. I usually go to my search market to download another one.
Reference: use Baidu to search for my tablet market and download thieves
 
Q: Can I use eclipse to write an android program that can be connected to a local mysql database? Sorry, there is no fortune

The android database can only connect to the built-in sqlite. You cannot create a connection pool in android.

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.