2012-03-13 62 views
3

Possible Duplicate:
compile opencv2.3.1 in ubuntu 11.10如何在Ubuntu 11.10解決的OpenCV 2.3.1編譯錯誤,由於FFmpeg的

如何準備你的環境,這樣你就可以正確地在Ubuntu 11.10編譯OpenCV的2.3.1?

我遵循OpenCV install guide,但它的指令非常複雜。

不過,我蒸成以下腳本:

sudo apt-get install --yes cmake libjpeg62 libjpeg62-dev libtiff4 libtiff4-dev libjasper1 libjasper-dev libpng12-0 libpng12-dev libavformat-dev libswscale-dev openexr zlibc zlib1g zlib1g-dev python2.7-dev libgtk-3-dev gcc g++ libtbb-dev 
cd /tmp 
wget --output-document=OpenCV-2.3.1a.tar.bz2 http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2/download?use_mirror=iweb 
tar -xvjf OpenCV-2.3.1a.tar.bz2 
cd OpenCV-2.3.1 
mkdir release 
cd release 
time cmake -D WITH_TBB=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON .. 
time make 

一切都成功地運行,當然除了make與錯誤退出:

/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1339:41: error: ‘guess_format’ was not declared in this scope 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1367:31: error: ‘av_alloc_format_context’ was not declared in this scope 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1411:9: warning: ‘int av_set_parameters(AVFormatContext*, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1363) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1411:35: warning: ‘int av_set_parameters(AVFormatContext*, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1363) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1415:5: warning: ‘void dump_format(AVFormatContext*, int, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1485) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1415:35: warning: ‘void dump_format(AVFormatContext*, int, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1485) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1442:15: warning: ‘int avcodec_open(AVCodecContext*, AVCodec*)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3650) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1442:36: warning: ‘int avcodec_open(AVCodecContext*, AVCodec*)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3650) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1479:13: warning: ‘int url_fopen(AVIOContext**, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avio.h:278) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1479:52: warning: ‘int url_fopen(AVIOContext**, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avio.h:278) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1485:5: warning: ‘int av_write_header(AVFormatContext*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1421) [-Wdeprecated-declarations] 
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1485:25: warning: ‘int av_write_header(AVFormatContext*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1421) [-Wdeprecated-declarations] 
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o] Error 1 
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 
make: *** [all] Error 2 

我該如何解決這個錯誤?

+0

這不是重複的。是的,它與另一個問題的名稱非常相似,但在閱讀每個問題的描述之後,編譯錯誤的原因是非常不同的。另一個問題有highgui問題,而我有一個ffmpeg的問題。 – Cerin 2012-03-14 16:05:34

回答

2

我認爲你沒有很好的ffmpeg庫。至少有兩種解決方案。 如果你需要的ffmpeg,嘗試安裝它感謝:

sudo apt-get install libavformat-dev libswscale-dev 

如果你不需要在你的OpenCV的應用程序中使用的ffmpeg,你可以嘗試禁用它補充說:

WITH_FFMPEG=OFF WITH_GSTREAMER=OFF 

到你的cmake配置行。

乾杯,

+0

正如你可以從我的問題腳本中看到的,我已經安裝了這些包... – Cerin 2012-03-14 16:07:39

+0

對不起,但你的腳本是:sudo apt-get install --yes cmake libjpeg62 libjpeg62-dev libtiff4 libtiff4-dev libjasper1 libjasper- dev libpng12-0 libpng12-dev libavformat-dev libswscale-dev openexr zlibc zlib1g zlib1g-dev python2.7-dev libgtk-3-dev gcc g ++ libtbb-dev。 我在這裏沒有看到ffmpeg – 2012-03-14 16:13:52

+0

對不起,您對。我確實安裝了它們,但忘記更新我的問題。 – Cerin 2012-03-14 18:01:59