ANDROID4.2.2NDK and source code development JNI Similarities and differences (2)

Source: Internet
Author: User

NDK Development Android.mk Writing samples

1.JNI contains multiple source files, and multiple files are compiled into different so files

(1) Jni/android.mk:
Include $ (call All-subdir-makefiles) (contains all subdirectories under ANDROID.MK)
Note: When writing a android.mk file,
Call All-subdir-makefiles and call all-makefiles-under,$ (Local_path) are different.
The former means "There are no files to compile in the current directory, please Shangzi the directory in Depth",
is a prescribed notation that tells the compiler to continue to recursion to the depths of the directory.
The latter, literally, should also be the same meaning.
However, consider a situation where if a file in the current directory needs to be compiled,
And in the current directory there are subdirectories, subdirectories also have files that need to be compiled,
The android.mk in the current directory, in addition to the statements that compile the files in the current directory,
Also include telling the compiler that after compiling the files in the current directory,
Continue to the sub-directory in-depth statements. There's a problem here,
How do you write the following statement? It's call All-subdir-makefiles,
or call all-makefiles-under,$ (Local_path)?
Here, after my experiments, it is impossible to write the former.
The compiler will no longer go into the subdirectory compilation after compiling the files in the current directory.
The latter, in other languages, can achieve our expectations.
(2) Jni/app_jni/android.mk
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module_tags: = Optional
Local_module: = Libcallapp_jni
Local_src_files: = Callapp_jni.cpp
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Local_shared_libraries: = libdl\
Liblog\
Libappupgrade\
Libapparea
Include $ (build_shared_library)

(3) Jni/app_area/android.mk
Local_path:= $ (call My-dir)
Include $ (clear_vars)
local_src_files:= \
APPAREA.C encrypt.c
local_module:= Libapparea

Include $ (build_shared_library)
(4) Jni/app_upgrade/android.mk

Local_path:= $ (call My-dir)
Include $ (clear_vars)
Local_module_tags: = Optional
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Local_shared_libraries: = Liblog Libapparea
local_src_files:= \
Appupgrade.c

local_module:= Libappupgrade
Include $ (build_shared_library)

2. JNI contains multiple so, no source files

(1) Jni/android.mk:
Include $ (call All-subdir-makefiles) (contains all subdirectories under ANDROID.MK)

(2) Jni/app_jni/android.mk
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module_tags: = Optional
Local_module: = Libcallapp_jni
Local_src_files: = Callapp_jni.cpp
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Local_shared_libraries: = libdl\
Liblog\
Libpre_appupgrade\
Libpre_apparea
Include $ (build_shared_library)

(3) Jni/app_area/android.mk
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module: = Pre_apparea
Local_src_files: =libapparea.so
Include $ (prebuilt_shared_library)

(4) Jni/app_upgrade/android.mk

Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module: = Pre_appupgrade
Local_src_files: =libappupgrade.so
Include $ (prebuilt_shared_library)


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.