FFmpeg的Andr​​oid上,未定义的引用libav codeC的功能,尽管它被列在命令行 [英] FFMpeg on Android, undefined references to libavcodec functions, although it is listed on command line

查看:361
本文介绍了FFmpeg的Andr​​oid上,未定义的引用libav codeC的功能,尽管它被列在命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个未解决的引用FFmpeg的libav codeC功能的问题,至今没有找到在其他地方(包括我的心):)

I have a problem with unresolved references to ffmpeg's libavcodec functions, so far failed to find the answer in other places (including my mind) :)

让我描述我的设置 - 它需要空间,但确实是基本的,这也许是因为我没能看到一些错误......

Let me describe my setup - it takes space, but is really basic, it might be that I'm failing to see some error...

我建立了一个与ffmpeg的R5 NDK工具链,ffmpeg的端口我从 http://bambuser.com/opensource 了(如建议这里的其他问题)。它建立了良好的,所以我把一些静态库在我的项目是这样的:

I built an FFMPeg with ndk r5 toolchain, ffmpeg port I got from http://bambuser.com/opensource (as recommended in other questions here). It built fine, so I put several static libraries in my project like this:

<project>/jni/bambuser_ffmpeg/libavcodec.a
<project>/jni/bambuser_ffmpeg/libavformat.a
<project>/jni/bambuser_ffmpeg/libavcore.a
<project>/jni/bambuser_ffmpeg/libavutil.a

接下来,我创建了一个Android.mk在bambuser_ffmpeg文件夹中列出这些库为prebuilt的:

Next, I created an Android.mk in bambuser_ffmpeg folder to list these libs as a prebuilt ones:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := bambuser-libavcore
LOCAL_SRC_FILES := libavcore.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := bambuser-libavformat
LOCAL_SRC_FILES := libavformat.a
include $(PREBUILT_STATIC_LIBRARY)

(same for other two libs)

接下来,我有在Android.mk引用这些库的另一个模块,建立了包含路径等:

Next, I have another module which references these libs in its Android.mk, sets up include paths, etc:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := ffmpegtest
LOCAL_STATIC_LIBRARIES := bambuser-libavcodec bambuser-libavcore bambuser-libavformat bambuser-libavutil
LOCAL_SRC_FILES := ffmpeg_test.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../bambuser_ffmpeg/include
LOCAL_LDLIBS    := -llog -lz

include $(BUILD_SHARED_LIBRARY)

最后,我有我的ffmpeg_test.cpp这是很基本的,像这样的:

And finally I have my ffmpeg_test.cpp which is really basic, like this:

#include <jni.h>

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}

extern "C" {
    JNIEXPORT jint JNICALL Java_com_the7art_ffmpegtest_PaintThread_testFFMpeg(JNIEnv* env, jobject obj, jstring fileName);
}

JNIEXPORT jint JNICALL Java_com_the7art_ffmpegtest_PaintThread_testFFMpeg(JNIEnv* env, jobject obj, jstring fileName)
{
    av_register_all();
    return 0;
}

当我运行的 NDK建造的,它编译罚款,但链接时,它打印一个尚未解决的参考几乎所有功能的 libav codeC 的。貌似只有这个LIB的功能未能位于:

When I run ndk-build, it compiles fine, but when linking it prints an unresolved reference to almost every function in libavcodec. Looks like only this lib's functions are failing to be located:

/home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(allformats.o):   在功能上 av_register_all:   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/allformats.c:47:   未定义的引用    AV codec_register_all   /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o):   在功能上 parse_frame_rate:   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:3240:   未定义的引用    av_parse_video_rate   /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o):   在功能上 parse_image_size:   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:3234:   未定义的引用    av_parse_video_size   /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o):   在功能上 flush_packet_queue:   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:1277:   未定义的引用    av_free_packet   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:1283:   未定义的引用    av_free_packet   /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o):   在功能 get_audio_frame_size:   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:766:   未定义的引用    av_get_bits_per_sample   /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o):   在功能    ff_interleave_add_packet:   /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:2909:   未定义的参考`av_dup_packet

/home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(allformats.o): In function av_register_all': /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/allformats.c:47: undefined reference to avcodec_register_all' /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o): In function parse_frame_rate': /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:3240: undefined reference to av_parse_video_rate' /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o): In function parse_image_size': /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:3234: undefined reference to av_parse_video_size' /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o): In function flush_packet_queue': /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:1277: undefined reference to av_free_packet' /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:1283: undefined reference to av_free_packet' /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o): In functionget_audio_frame_size': /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:766: undefined reference to av_get_bits_per_sample' /home/dimka/src/mobile/android/ffmpegtest/obj/local/armeabi/libavformat.a(utils.o): In function ff_interleave_add_packet': /home/dimka/work/suzy/tmp/ffmpeg-android/ffmpeg/libavformat/utils.c:2909: undefined reference to `av_dup_packet'

等等...

我想不通的是为什么发生这种情况。我试图运行的 NDK建造V = 1 的检查实际连接命令, libav codeC 的坐在那里完全正确的,像它应该。所有其他的ffmpeg库在那里了。

I fail to figure why this is happening. I tried running ndk-build V=1 to check the actual linking command, and libavcodec is sitting there perfectly right, like it should. All other ffmpeg libs are there too.

任何提示?

推荐答案

我一直在使用ffmpeg的一些Android的工作了。我有点不同,虽然做我的身材。我采取的lib * .a文件和包括来自bambuser.com build目录,只是直接把它们包含在我的JNI目录,我的Andr​​oid.mk是这样的:

I've been using ffmpeg for some Android work too. I do my build a bit different though. I take the lib*.a files and the include dir from the bambuser.com build and just directly include them in my jni directory, my Android.mk looks like this:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := ndk1
LOCAL_SRC_FILES := native.c

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_LDLIBS := -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib -L$(LOCAL_PATH) -lavformat -lavcodec -lavdevice -lavfilter -lavutil -lswscale -llog -ljnigraphics -lz -ldl -lgcc

include $(BUILD_SHARED_LIBRARY)

有可能是在那里一些克鲁夫特,但也许它会帮你指明正确的方向。我尝试以下一些在NDK示例项目中规定的形式,如您有。捆绑了库成一个模块,然后引用了。但最终回落就简单直接包括刚刚得到的东西的工作,而且至今还没有理由重新考虑。

There might be some cruft in there, but maybe it'll help point you in the right direction. I tried following some of the forms laid out in the NDK example projects like you have. Bundling up the libs into a module and then referencing that. But ended up falling back on the simple direct include just to get things working, and so far haven't had reason to revisit it.

这篇关于FFmpeg的Andr​​oid上,未定义的引用libav codeC的功能,尽管它被列在命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆