About jni compiling 32-bit and 64-bit dynamic libraries (Android. mk and Application. mk files), jniapplication. mk

Source: Internet
Author: User

About jni compiling 32-bit and 64-bit dynamic libraries (Android. mk and Application. mk files), jniapplication. mk

 

The latest new project needs to compile a 64-bit dynamic library, which records how to configure it.

Add the Android. mk and Application. mk files to the jni directory.

 

 

Application. mk

1 APP_ABI := armeabi armeabi-v7a arm64-v8a

Android. mk

1 LOCAL_PATH := $(call my-dir)2 include $(CLEAR_VARS)3 4 LOCAL_MODULE := hello-jni5 LOCAL_SRC_FILES := hello-jni.c6 7 include $(BUILD_SHARED_LIBRARY)

 

After these two mk files are added, the compilation will generate the library file of armeabi, armeabi-v7a, arm64-v8a.

 

Supplement:

 

Android. mk files are used to describe your source files to build system (compile system). For example, you need to compile a static library (. a file) or a dynamic library (. so file), which will be parsed once or multiple times by build system.

Application. mk is part of GNU Makefile and describes the modules (static or dynamic libraries) in the compilation system on which your Application depends ).

 

In the Android. mk file, determine whether the value is 64-bit or 32-bit.

 1 ifneq ($(filter $(NDK_KNOWN_DEVICE_ABI64S),$(TARGET_ARCH_ABI)),) 2 # 64-bit ABIs 3  4 …… 5 …… 6  7 else 8 # 32-bit ABIs 9 10 ……11 ……12 ……13 14 15 endif

 

Compilation target type

Each Android. mk file will be followed by a description of the type of output to be compiled, for example:

 

Compile dynamic library: include $ (BUILD_SHARED_LIBRARY)

Compile static library: include $ (BUILD_STATIC_LIBRARY)

Output the compiled so file: include $ (PREBUILT_SHARED_LIBRARY)

Compile the jar file: include $ (BUILD_JAVA_LIBRARY)

Output the compiled apk file: include $ (BUILD_PREBUILT)

Compile the apk file: include $ (BUILD_PACKAGE)

 

 

 

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.