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

相關文章
相關標籤/搜索