作者:直由飞翔_447 | 来源:互联网 | 2023-09-25 10:14
我正在按照与halfninja构建相同的模式构建ffmpeg:通过JNI从Java获取ffmpeg的main。我使用以下选项构建了ffmpeg:.configure--prefix
我正在按照与halfninja构建相同的模式构建 ffmpeg:通过JNI从Java获取ffmpeg的main
。 我使用以下选项构建了ffmpeg:
./configure --prefix=$PREFIX --disable-shared --enable-static --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-symver --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --target-os=linux --arch=arm --enable-cross-compile --sysroot=$SYSROOT --extra-cflags="-Os -fpic $ADDI_CFLAGS" --extra-ldflags="$ADDI_LDFLAGS"
$PREFIX
, TOOLCHAIN
,…从我的NDK设置为相应的文件夹。 $ADDI_CFLAGS
设置为-marm
, $ADDI_LDFLAGS
和$ADDITIONAL_CONFIGURE_FLAGS
$ADDI_LDFLAGS
设置。 生成的静态库:
$ ls -1 android / arm / lib / libavcodec.a libavdevice.a libavfilter.a libavformat.a libavutil.a libswresample.a libswscale.a pkgconfig
我用一个Android.mk
文件公开它们,ffmpeg是在$NDK/sources/ffmpeg-2.1.1
构建的:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= libavdevice LOCAL_SRC_FILES:= lib/libavdevice.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE:= libavcodec LOCAL_SRC_FILES:= lib/libavcodec.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE:= libavformat LOCAL_SRC_FILES:= lib/libavformat.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE:= libswscale LOCAL_SRC_FILES:= lib/libswscale.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE:= libavutil LOCAL_SRC_FILES:= lib/libavutil.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE:= libavfilter LOCAL_SRC_FILES:= lib/libavfilter.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE:= libwsresample LOCAL_SRC_FILES:= lib/libswresample.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_STATIC_LIBRARY)
所以,到那里,一切看起来都不错。 现在,我尝试将ffmpeg
二进制等价物构建为静态库。 我在我的jni
文件夹中复制了(并且现在没有更改单个字符) ffmpeg.c
, ffmpeg.h
, cmdutils.c
, cmdutils.h
, ffmpeg_opt.c
和ffmpeg_filter.c
。 我在这个文件夹中也有两个直接与JNI相关的文件(从halfninja的build中复制,我刚刚更改了包名)。 这是相关的Android.mk
:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_C_INCLUDES := /Applications/android-ndk-r9b/sources/ffmpeg-2.1.1 LOCAL_CFLAGS := -Wdeprecated-declarations LOCAL_MODULE := videokit ANDROID_LIB := -landroid LOCAL_LDLIBS += -llog -ljnigraphics -lz LOCAL_SRC_FILES := videokit/com_rfc_video_ffmpeg_Videokit.c videokit/ffmpeg.c videokit/cmdutils.c videokit/ffmpeg_opt.c videokit/ffmpeg_filter.c LOCAL_SHARED_LIBRARIES := libavdevice libavformat libavfilter libavcodec libwscale libavutil libswresample libswscale libpostproc include $(BUILD_SHARED_LIBRARY) $(call import-module,ffmpeg-2.1.1/android/arm)
一切都很好,但没有链接。 这是第一个错误:
[armeabi] SharedLibrary:libvideokit.so /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../ .. /../arm-linux-androideabi/bin/ld:./obj/local/armeabi/objs/videokit/videokit/cmdutils.o:in function print_all_libs_info.constprop.5:jni / videokit / cmdutils.c:1063:错误:对'swresample_version'的未定义引用 /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../ .. /../arm-linux-androideabi/bin/ld:./obj/local/armeabi/objs/videokit/videokit/cmdutils.o:in function print_all_libs_info.constprop.5:jni / videokit / cmdutils.c:1063:错误:对'swresample_configuration'的未定义引用 /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../ .. /../arm-linux-androideabi/bin/ld:./ obj / local / armeabi / objs / videokit / videokit / cmdutils.o:in function opt_default:jni / videokit / cmdutils.c:558:error:undefined reference到'swr_get_class' /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../ .. /../arm-linux-androideabi/bin/ld:./obj/local/armeabi/objs/videokit/videokit/cmdutils.o:in function opt_default:jni / videokit / cmdutils.c:561:error:undefined reference 'swr_alloc' /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../ .. /../arm-linux-androideabi/bin/ld:./obj/local/armeabi/objs/videokit/videokit/cmdutils.o:in function opt_default:jni / videokit / cmdutils.c:563:error:undefined reference 'swr_free' /Applications/android-ndk-r9b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../ .. /../arm-linux-androideabi/bin/ld:./obj/local/armeabi/objs/videokit/videokit/ffmpeg_opt.o:in function show_help_default:jni / videokit / ffmpeg_opt.c:2464:error:undefined reference到'swr_get_class'
我不明白的是这些函数是在libswresample.a
中定义和提供的,我将链接到:
arm-linux-androideabi-nm /Applications/android-ndk-r9b/sources/ffmpeg-2.1.1/android/arm/lib/libswresample.a | grep -i -e swr_get_class -e swresample_version 000001d4 T swr_get_class 00000178 T swresample_version
我究竟做错了什么? 还有另一种更简单的方法可以将ffmpeg公开为通过JNI提供的静态库吗? (我不使用halfninja,因为我需要至少ffmpeg 1.1,而他的是0.9)。
你的名字有点混乱:在一个地方,你称之为libwsresample
,其他地方是libswresample
。
检查所有名称是否一致。
需要了解更多c/c++开发分享使用ffmpeg 2.1.1 for Android时未定义的引用,也可以关注C/ C++技术分享栏目—编程笔记
以上就是c/c++开发分享使用ffmpeg 2.1.1 for Android时未定义的引用相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注(编程笔记)。