安装opencv时候遇到terminate called after throwing an instance of 'cv::Exception'解决方法

安装opencv的时候遇到如下问题

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/nick/.Apps/opencv/modules/highgui/src/window.cpp, line 516
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/nick/.Apps/opencv/modules/highgui/src/window.cpp:516: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

解决方法:

先检查是否安装libgtk2.0-dev

sudo aptitude search libgtk2.0-dev

 

如果正确安装,则会显示 

i  libgtk2.0-dev              - development files for the GTK+ library 
p  libgtk2.0-dev:i386         - development files for the GTK+ library

接着,你需要重新build opencv文件。

cd /home/user_name/OpenCv
mkdir Release
cd Release

接着,进行执行cmake命令

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..

谨记设置WITH_GTK=ON,然后接着执行

make
sudo make install

这样,就完美解决问题,开始编程测试一下吧。

你可能感兴趣的:(OpenCv)