Ndk compiles and uses static and dynamic libraries
Case 1: Compile the static library
Case 2: Compile the dynamic library
Case 3: Compile the dynamic library + static library
Scenario 4: existing third-party static libraries (dynamic libraries), compiling static libraries (dynamic libraries)
By default, all codes and files are under $ Project/JNI. Otherwise, special instructions are provided.
Case 1: Compile the static library
File Android. mk:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
Local_module: = hello-JNI
Local_src_files: = hello-jni.c
Include $ (Build _Static_ Library)
File application. mk:
App_modules: = Hello-JNI
Case 2: Compile the dynamic library
File Android. mk:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
Local_module: = hello-JNI
Local_src_files: = hello-jni.c
Include $ (Build_shared_library)
Case 3: Compile the dynamic library + static library
File Android. mk:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
Local_module: = mylib_static
Local_src_files: = SRC. c
Include $ (Build_static_library)
Include $ (clear_vars)
Local_module: = mylib_shared
Local_src_files: = src2.c
Local_static_libraries: = Mylib_static
Include $ (Build_shared_library)
Scenario 4: existing third-party static libraries (dynamic libraries), compiling static libraries (dynamic libraries)
File Android. mk:
Local_path: = $ (call my-DIR)
Include $ (clear_vars)
Local_module: = thirdlib1 # name it whatever
Local_src_files: =$ (Target_arch_abi)/libthird1.a# Or $ (so_path)/Libthird1.so
# Local_export_c_includes: = $ (local_path)/include
Include $ (Prebuilt_static_library) # OrPrebuilt _Shared_ Library
Include $ (clear_vars)
Local_module: = mylib_use_thirdlib
Local_src_files: = SRC. c
Local_static_libraries: = Thirdlib1 # OrLocal_Shared_ Library
Include $ (Build_shared_library) # If a static library is compiled, application. mk is required.