如何在Android NDK中调用第三方库文件(.so)

2024-11-01 10:20:37
有2个网友回答
网友(1):

1.在project/jni目录下创建prebuilt子目录(目录名可自定义).
2.将第三方.so放到prebuilt中,并创建Android.mk, 内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := xxx
LOCAL_SRC_FILES := libxxx.so
include $(PREBUILT_SHARED_LIBRARY)
3.在project/jni/Android.mk中加入
LOCAL_SHARED_LIBRARIES := xxx
4.在project/jni/android.mk的最后加入
include $(LOCAL_PATH)/prebuilt/Android.mk
5.运行cygwin, 到project目录下, 运行$NDK/ndk-build

网友(2):

1.在project/jni目录下创建prebuilt子目录(目录名可自定义).2.将第三方.so放到prebuilt中,并创建Android.mk, 内容如下: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := xxx LOCAL_SRC_FILES := libxxx.so include $(PREBUILT_SHARED_LIBRARY)3.在project/jni/Android.mk中加入 LOCAL_SHARED_LIBRARIES := xxx4.在project/jni/android.mk的最后加入 include $(LOCAL_PATH)/prebuilt/Android.mk5.运行cygwin, 到project目录下, 运行$NDK/ndk-build