gpt4 book ai didi

android - 为什么android Jni在调用共享库中的c方法时崩溃?

转载 作者:行者123 更新时间:2023-11-30 03:27:12 25 4
gpt4 key购买 nike

我已经将 ffmpeg-1.2 编译成 libffmpeg.so,然后像这样在 Jni 中加载它:

    handle = dlopen("/data/data/com.example.hellojni/lib/libffmpeg.so", RTLD_LAZY);
LOGE("%s() handle=%p", __func__, handle);

if (handle) {
func_t dlfunc = (func_t)dlsym(handle, "main");
LOGE("%s() dlfunc=%p", __func__, dlfunc);
if (dlfunc) {
err = dlfunc(argc, argv); // Crashed!!

日志:

17:11:10.499: E/Videokit(6642): __run_ffmpeg_main() handle=0x400c8370   // got handle!!
17:11:10.499: E/Videokit(6642): __run_ffmpeg_main() dlfunc=0x511326f8 // got symbol!!
17:11:10.689: D/BluetoothAdapter(773): 1094265936: getState() : mService = null. Returning STATE_OFF
17:11:10.709: W/Settings(773): Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
17:11:10.949: I/ActivityManager(492): Process com.example.hellojni (pid 6642) has died.
17:11:10.969: D/dalvikvm(6655): Late-enabling CheckJNI
17:11:10.969: I/ActivityManager(492): Start proc com.example.hellojni for activity com.example.hellojni/.HelloJni: pid=6655 uid=10065 gids={50065, 1006, 1015, 1028}
17:11:11.009: I/dalvikvm(6655): Turning on JNI app bug workarounds for target SDK version 8…
17:11:11.049: D/dalvikvm(6655): Trying to load lib /data/app-lib/com.example.hellojni-1/libhello-jni.so 0x40f0a808
17:11:11.049: D/dalvikvm(6655): Added shared lib /data/app-lib/com.example.hellojni-1/libhello-jni.so 0x40f0a808
17:11:11.049: D/dalvikvm(6655): No JNI_OnLoad found in /data/app-lib/com.example.hellojni-1/libhello-jni.so 0x40f0a808, skipping init

Android.mak:

LOCAL_PATH              := $(call my-dir)
FFMPEG_DIR := $(LOCAL_PATH)/ffmpeg-1.2.1

FFMPEG_LIBS := $(addprefix $(FFMPEG_DIR)/, \
....)

# libffmpeg

include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_CFLAGS += -g -I$(FFMPEG_DIR) -Wno-deprecated-declarations
LOCAL_LDLIBS += -llog -lz $(FFMPEG_LIBS) # x264/libx264.a
LOCAL_C_INCLUDES := ...
LOCAL_SRC_FILES := ...
include $(BUILD_SHARED_LIBRARY)

# libhello-jni

include $(CLEAR_VARS)
LOCAL_ALLOW_UNDEFIND_SYMBOLS=false
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -ldl -llog -ljnigraphics -lz -lm
include $(BUILD_SHARED_LIBRARY)

最佳答案

由于codec/filter/muxer/demuxer/protocol missing导致,修改构建脚本重新构建,解决!

关于android - 为什么android Jni在调用共享库中的c方法时崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18055445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com