FFMpeg在Android上,未定义引用libavcodec函数,尽管它在命令行中列出 [英] FFMpeg on Android, undefined references to libavcodec functions, although it is listed on command line

查看:176
本文介绍了FFMpeg在Android上,未定义引用libavcodec函数,尽管它在命令行中列出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个未解决的对ffmpeg的libavcodec函数的引用的问题,到目前为止还没有找到其他地方的答案(包括我的想法):)

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...

我用ndk r5工具链构建了一个FFMPeg ,我从 http://bambuser.com/opensource 获取的ffmpeg端口(按照其他问题的建议)。它构建良好,所以我在我的项目中放置了几个静态库:

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

接下来,我在bambuser_ffmpeg文件夹中创建了一个Android.mk,将这些库列表预先构建为: / p>

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-build ,它编译好的,但链接时,会将未解析的引用打印到libavcodec 中几乎所有的函数。看来只有这个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:
未定义引用
avcodec_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 / ff mpegtest / 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-build V = 1 来检查实际的链接命令,而libavcodec 正好坐在那里,就像它应该的那样。所有其他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构建中的include dir,并直接将它们包含在我的jni目录中,我的Android.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示例项目中列出的一些表单,就像您一样。将libs捆绑到一个模块中,然后引用它。但最终只是简单的直接包括只是为了让事情工作,到目前为止还没有理由重新审视。

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在Android上,未定义引用libavcodec函数,尽管它在命令行中列出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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