编译时报错 cvNamedWindow’问题

运行程序时,Ubuntu  系统显示窗口的时候遇到了这个问题

error: (-2: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 function ‘cvNamedWindow’

原因:

在Linux平台上编译opencv源代码库时,当使用./configure进行配置时,未检测到gtk2.0的开发库, 因此,当运行make命令时,它将在没有任何UI支持的情况下编译该库。 不仅需要在系统上具有gtk运行库,而且还需要gtk开发库才能在ui支持下成功编译opencv。

解决办法:删除opencv库,安装GTK+ 2.x,重新编译opencv。

apt-get install libgtk2.0-dev pkg-config
apt-get install pkg-config

 命令查看GTK+ 2.x版本:

pkg-config --modversion gtk+-2.0

安装cmake:

查看当前cmake的版本:cmake --version
下载cmake安装包:wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz

cd cmake-3.9.2
./configure
sudo make && make install

查看版本号,验证: cmake --version
如果没有的话,我们就需要修改用户的PATH路径,把cmake路径加入用户环境变量,可以运行如下命令:

$ echo "export PATH=$PATH:/usr/local/bin" >> ~/.bashrc  

下载opencv源码:

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

打开cmake进行编译:

cmake-gui

 

你可能感兴趣的:(编译时报错 cvNamedWindow’问题)