我正在使用gf版本的ffmpeg(旧版本成功使用后更新),当我尝试编译我的项目时我得到了
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:376: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:222: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_init_resample':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:163: undefined reference to `swr_init'
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:169: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:236: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_flush_resample':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:117: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:408: undefined reference to `swr_close'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_flush':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:557: undefined reference to `swr_close'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_close':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:579: undefined reference to `swr_free'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_init':
/home/user/projects/ffmpleglast/ffmpeg/libavcodec/opusdec.c:629: undefined reference to `swr_alloc'
似乎是版本冲突?但如何删除错误的库?它们似乎是今天的构建。
ls -l /usr/local/lib
-rw-r--r-- 1 root root 136509684 may 29 14:47 libavcodec.a
-rw-r--r-- 1 root root 1853574 may 29 14:47 libavdevice.a
-rw-r--r-- 1 root root 9689456 may 29 14:47 libavfilter.a
-rw-r--r-- 1 root root 46282270 may 29 14:47 libavformat.a
-rw-r--r-- 1 root root 2092250 may 29 14:47 libavutil.a
-rw-r--r-- 1 root root 67942 may 12 11:29 libBasicUsageEnvironment.a
-rw-r--r-- 1 root root 2200164 apr. 10 10:11 libfftw3.a
-rwxr-xr-x 1 root root 872 apr. 10 10:11 libfftw3.la
-rw-r--r-- 1 root root 94188 may 12 11:29 libgroupsock.a
-rw-r--r-- 1 root root 2236084 may 12 11:29 libliveMedia.a
-rw-r--r-- 1 root root 546506 may 29 14:47 libswresample.a
-rw-r--r-- 1 root root 4813716 may 29 14:47 libswscale.a
-rw-r--r-- 1 root root 14588 may 12 11:29 libUsageEnvironment.a
答案 0 :(得分:3)
当我构建一个试图引入ffmpeg DLL的DLL时,我遇到了同样的错误。
我错过了ffmpeg包含文件的外部C语句:
extern "C"
{
#include "include\libavcodec\avcodec.h"
#include "include\libavformat\avformat.h"
#include "include\libavformat\avio.h"
#include "include\libswscale\swscale.h"
#include "include\libavutil\dict.h"
#include "include\libavutil\frame.h"
}
我还发现我需要将DLL作为依赖项添加到解决方案中,或者使用pragma语句将其包含在内。
#pragma comment(lib, "..\\..\\..\\..\\contrib\\ffmpeg\\lib\\avformat.lib")
#pragma comment(lib, "..\\..\\..\\..\\contrib\\ffmpeg\\lib\\swscale.lib")
#pragma comment(lib, "..\\..\\..\\..\\contrib\\ffmpeg\\lib\\avutil.lib")
这是在Windows上,只是告诉VS指定的lib文件详细说明了那些相同位置的DLL的接口。你不会在Linux上需要它,因为你的-lavformat等语句应该覆盖它,但我怀疑你可能需要extern C部分。
如果它仍然没有帮助,可以在编译/链接上使用详细模式,这样你就可以看到从哪个位置传来的内容。
答案 1 :(得分:1)
您可能还在系统中安装了ffmpeg(在/ usr / lib和/ usr / include中)。尝试强制包含-I参数的路径(/ usr / local / include)和带-L参数的库路径(/ usr / local / lib)