2012-03-11 95 views
2

我想編譯this example編譯ffmpeg和opencv時出錯

on Ubunto。這是編譯命令:

g++ video.cpp -o video `pkg-config --cflags opencv` `pkg-config --libs opencv` -lpthread -lavutil -lavformat -lavcodec -lz 

,這是我收到的錯誤:

 /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 

請指教。 謝謝, Nahum

+0

請使用代碼標籤(大括號重新格式化你的問題一個純C項目:{ }圖標),以使錯誤輸出更具可讀性。 – 2012-03-11 08:05:05

回答

1

您正在從C++程序調用FFmpeg庫。你是否打包了#include調用相關頭文件中的

extern "C" { ... } 

構造?頭文件沒有自動C++支持。

編輯:

予讀出的鏈接的例子源;它做對了。

我認爲問題是版本差異。這個例子已經超過2年了,FFmpeg API已經開始了。您可能需要自行升級API調用。

+0

我',使用extern和謝謝,我會檢查升級isuue – nmnir 2012-03-11 09:34:52

0

據我記得,你應該使用cmake來建立opencv。 cmake根據c編譯器,庫支持,線程庫等檢查你的環境,並在編譯時自動設置一些標誌。所以不要試圖自己編譯它。只需按照此處的步驟操作http://opencv.willowgarage.com/wiki/InstallGuide_Linux

+0

謝謝,我用cmake – nmnir 2012-03-11 09:33:26

4

見libav faq.txi

@我使用Libav從我的C++應用程序中,但鏈接器抱怨缺少這似乎是可用的符號。

Libav是用C99數學的特點,爲了使C++ 使用它們,你必須追加-D__STDC_CONSTANT_MACROS您CXXFLAGS