How to link a prebuilt shared Library to an Android NDK project?

前端 未结 4 1871
醉话见心
醉话见心 2020-11-27 18:28

Here I used this Android.mk file in jni/ folder.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_PATH := $(call my-dir)
         


        
4条回答
  •  囚心锁ツ
    2020-11-27 19:05

    Here is a complete Android.mk file for using a 3rd party shared library. The library (libffmpeg.so) is placed in the jni folder. Its "LOCAL_EXPORT_C_INCLUDES" specifies where the header files are kept for the library.

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE := ffmpeg
    LOCAL_SRC_FILES := libffmpeg.so
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ffmpeg/libs/arm-linux-androideabi4.7_1/include
    include $(PREBUILT_SHARED_LIBRARY)
    
    
    include $(CLEAR_VARS)
    LOCAL_MODULE    := ffmpegandroid
    LOCAL_SRC_FILES := ffmpegandroid.c
    LOCAL_SHARED_LIBRARIES := ffmpeg
    include $(BUILD_SHARED_LIBRARY)
    

    If you wanted to support multiple architectures then you could specify:

    APP_ABI := armeabi armeabi-v7a x86 mips
    

    in your jni/Application.mk and change the LOCAL_SRC_FILES to something like:

    LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libffmpeg.so
    

    and place a libffmpeg.so at jni/armeabi/libffmpeg.so, jni/armeabi-v7a/libffmpeg.so etc ..

提交回复
热议问题