ffmpeg库使用,undefined reference错误

ffmpeg用g++编译时的注意事项spa

编译时出现如下错误:.net

错误一:code

undefined reference to `av_register_all()'
undefined reference to `avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)'
undefined reference to `avformat_find_stream_info(AVFormatContext*, AVDictionary**)'
undefined reference to `avcodec_find_decoder(AVCodecID)'
undefined reference to `avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)'
undefined reference to `avcodec_alloc_frame()'
undefined reference to `avcodec_alloc_frame()'orm

解决方法:
用extern "C"{}把头文件包含起来。
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
get

 

错误二:input

ffmpeg_4.0.2/lib/libavcodec.a(tiff.o): In function `tiff_uncompress_lzma':
ffmpeg-4.0.2/libavcodec/tiff.c:398: undefined reference to `lzma_stream_decoder'
ffmpeg-4.0.2/libavcodec/tiff.c:403: undefined reference to `lzma_code'
ffmpeg-4.0.2/libavcodec/tiff.c:404: undefined reference to `lzma_end'io

解决方法:加上-llzma选项编译

 

参考的编译选项:function

gcc push.cpp -g -I ffmpeg_4.0.2/include -L ffmpeg_4.0.2/lib -lavform我的中心at -lavcodec -lswresample -lavutil -pthread -lbz2  -lz -lm -llzmaform

相关文章
相关标签/搜索