ffmpeg用g++編譯時的注意事項

ffmpeg用g++編譯時的注意事項

1、編譯時出現下面錯誤
libavutil/common.h:185: 錯誤:‘UINT64_C’ 在此作用域中尚未聲明

解決方法:
libavutil/common.h增加如下代碼
//user add start
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
//user add end


2、編譯鏈接時找不到對應的函數
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()'

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章