我想在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,我没有错误。但我不知道如何成功加载库?
非常感谢!