OpenCV2.3.1在Ubuntu11.10上編譯錯誤解決方法
經過上次介紹Ubuntu 全新編譯安裝 OpenCV 2.3之後,很快,新的2.3.1又出來了,經不住誘惑,馬上試試
但是,不知道大家在編譯最新的2.3.1的時候出現錯誤沒,反正我出現錯誤了,具體編譯錯誤如下:
[ 35%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o In file included from /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg.cpp:45:0: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::reopen()’: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:486:5: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:486:52: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:494:5: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:494:50: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::open(const char*)’: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:524:15: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:524:63: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:541:9: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:541:54: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:547:13: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::grabFrame()’: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:640:34: error: ‘avcodec_decode_video’ was not declared in this scope /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘const char* icvFFMPEGErrStr(int)’: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:917:10: error: ‘AVERROR_NUMEXPECTED’ was not declared in this scope /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:921:10: error: ‘AVERROR_NOFMT’ was not declared in this scope /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:923:10: error: ‘AVERROR_IO’ was not declared in this scope /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:925:10: error: ‘AVERROR_NOMEM’ was not declared in this scope /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘AVStream* icv_add_video_stream_FFMPEG(AVFormatContext*, CodecID, int, int, int, double, int)’: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:1012:70: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope In file included from /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg.cpp:45:0: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘void CvVideoWriter_FFMPEG::close()’: /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:1298:3: warning: ‘int url_fclose(AVIOContext*)’ is deprecated (declared at /usr/include/libavformat/avio.h:279) [-Wdeprecated-declarations] /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:1298:20: warning: ‘int url_fclose(AVIOContext*)’ is deprecated (declared at /usr/include/libavformat/avio.h:279) [-Wdeprecated-declarations]
很明顯,是ffmpeg的問題,在目前的Ubuntu下版本不夠高,所以,我就開始一番查詢,終於讓我找到了一篇好文章:
刪掉這些舊的ffmpeg x264 libx264-dev:
sudo apt-get remove ffmpeg x264 libx264-dev
- 下載x264和ffmpeg所有的依賴:
sudo apt-get update
sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev
- 安裝 gstreamer:
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
./configure --enable-static
make
sudo make install
- 下載安裝 ffmpeg.
- 配置編譯 ffmpeg:
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
make
sudo make install
- 安裝 gtk:
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
- 安裝 libjpeg:
sudo apt-get install libjpeg62 libjpeg62-dev
抄襲結束,由於編譯OpenCV差不多,所以就不抄了。。。
make
sudo make install