1

我想在 jni 的 c++ scr 文件中加载一个 .so 库。

我想在 SunniWell.cpp 中加载 lib_H264_dec_arm11_elinux.so:

dl_handle = dlopen("libcoder/lib_H264_dec_arm11_elinux.so", RTLD_LAZY);

Jni 文件将被编译为 libMediaConfig.so,Android.mk 为:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := MediaConfig
LOCAL_SRC_FILES := MediaConfig.cpp \
               SunniWell.cpp \
               hwcodec.cpp
LOCAL_C_INCLUDES:= ${LOCAL_PATH}/jni \
               ${LOCAL_PATH}/jni/hwcodec.h \
               ${LOCAL_PATH}/jni/SunniWell.h
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
LOCAL_SHARED_LIBRARIES:= ${LOCAL_PATH}/jni/libcoder/lib_H264_dec_arm11_elinux

include $(BUILD_SHARED_LIBRARY)

和java加载媒体config.so:

static {
    System.loadLibrary("MediaConfig");
}

但我得到了错误:

D/dalvikvm(9467): Trying to load lib /data/data/com.qiyi.mediaconfig/lib/libMediaConfig.so 0x4115e318
D/dalvikvm(9467): Added shared lib /data/data/com.qiyi.mediaconfig/lib/libMediaConfig.so 0x4115e318
D/dalvikvm(9467): No JNI_OnLoad found in /data/data/com.qiyi.mediaconfig/lib/libMediaConfig.so 0x4115e318, skipping init
A/libc(9467): Fatal signal 11 (SIGSEGV) at 0x400d54a8 (code=2)

我确信这是因为在 cpp 文件中加载了 lib_H264_dec_arm11_elinux.so。如果我删除加载 lib_H264_dec_arm11_elinux.so,我不会收到错误。但是我不知道如何成功加载库?

非常感谢!

4

0 回答 0