在 Ubuntu 12.04 上安装 OpenCV
我正在尝试在 Ubuntu 上安装 OpenCV 2.4.2,但遇到如下错误:
I am trying to install OpenCV 2.4.2 on Ubuntu and am running into errors as below:
[ 11%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_gtk.cpp.o
In file included from /usr/local/include/glib-2.0/glib/gasyncqueue.h:30:0,
from /usr/local/include/glib-2.0/glib.h:32,
from /usr/local/include/gtk-2.0/gdk/gdktypes.h:32,
from /usr/local/include/gtk-2.0/gdk/gdkcolor.h:4,
from /usr/local/include/gtk-2.0/gdk/gdk.h:30,
from /usr/local/include/gtk-2.0/gtk/gtk.h:31,
from /opt/opencv/OpenCV-2.4.2/modules/highgui/src/window_gtk.cpp:48:
/usr/local/include/glib-2.0/glib/gthread.h:233:27: error: variable or field 'g_static_mutex_init' declared void
/usr/local/include/glib-2.0/glib/gthread.h:233:27: error: 'GStaticMutex' was not declared in this scope
/usr/local/include/glib-2.0/glib/gthread.h:233:41: error: 'mutex' was not declared in this scope
/usr/local/include/glib-2.0/glib/gthread.h:233:41: note: suggested alternative:
/usr/include/tbb/mutex.h:48:7: note: 'tbb::mutex'
我检查了所有依赖项并按如下方式安装它们:
I checked all dependencies and installed them as below:
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
我还在 CMakeCache.txt 中添加了以下路径
I also added the following paths to CMakeCache.txt
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include/
感谢任何帮助.
谢谢,
席德
我根据评论切换到 QT,这让我摆脱了必须手动插入 CMakeCache.txt 的 gtk 包含.但是我仍然遇到安装错误(可能是由于 glib 包含)所以我在 CMAKE 中关闭了 GSTREAMER,现在我可以安装 opencv.这项工作可行吗?
Edit : I switched to QT as per comment and that allowed me to get rid of the gtk include that I had to manually insert into CMakeCache.txt. But I was still getting an installation error (maybe due to the glib include) so I turned GSTREAMER off in CMAKE and now I am able to install opencv. Is this work around feasible?
除非您需要一些特定的编译选项,否则您应该能够直接从 Synaptic(版本 2.3.1)安装 OpenCV;库已在默认存储库中.
Unless you need some specific compilation options, you should be able to install OpenCV right from Synaptic (version 2.3.1); the libraries are already in the default repository.
如果你需要更新的版本,你也应该可以找到一些带有OpenCV预编译的PPA,比如https://launchpad.net/~yjwong/+archive/opencv2 或 https://launchpad.net/~limparissoft/+archive/opencv-ppa
If you need a newer version, you should also be able to find some PPAs with OpenCV precompiled, such as https://launchpad.net/~yjwong/+archive/opencv2 or https://launchpad.net/~limparissoft/+archive/opencv-ppa