编译ffmpeg和opencv时出错

nmn*_*nir 2 ubuntu opencv ffmpeg

我正在尝试编译这个例子

在Ubunto上.这是编译命令:

    g++ video.cpp -o video `pkg-config --cflags opencv` `pkg-config --libs opencv` -lpthread -lavutil -lavformat -lavcodec -lz
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

     /usr/local/include/libavutil/common.h:173:47: error: ‘UINT64_C’ was not declared in this scope
     video.cpp: In member function ‘int FFread::init(char*)’:
     video.cpp:24:56: error: ‘av_open_input_file’ was not declared in this scope
     video.cpp:28:5: warning: ‘int av_find_stream_info(AVFormatContext*)’ is deprecated      (declared at /usr/local/include/libavformat/avformat.h:1266) [-Wdeprecated-declarations]
     video.cpp:28:35: warning: ‘int av_find_stream_info(AVFormatContext*)’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1266) [-Wdeprecated-declarations]
     video.cpp:32:36: error: ‘dump_format’ was not declared in this scope
     video.cpp:37:48: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

请指教.谢谢,Nahum

小智 5

请参见libav faq.txi

@我在我的C++应用程序中使用了Libav,但是链接器抱怨缺少似乎可用的符号.

Libav是一个使用C99数学特性的纯C项目,为了使C++能够使用它们,你必须将-D__STDC_CONSTANT_MACROS附加到你的CXXFLAGS