Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.

@Ubuntu16.04 安装opencv3.4.1后,c++程序编译通过,执行可执行文件时报错 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/bush/opencv/OpenCV-2.3.0/modules/highgui/src/window.cpp

搜了很多的博客,都说是需要卸载重新安装opencv。但是卸载这一步我就耽误了很久,因为卸载不干净!!!
1、卸载方法:网上相关的博客很多,举个例子:https://blog.csdn.net/haoqimao_hard/article/details/82049565

a.找到opencv的安装路径,把opencv-3.4.1文件夹删除。
b.执行下面命令:
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
上面的命令执行后,我还是没有卸载干净!!!!
输入:pkg-config opencv --modversion。还是显示3.4.1,很崩溃。
后来搜到下面的这个命令:
cd /usr
sudo find / -iname " * opencv * "
网上说这个命令不能输错,我就粘了过去,双引号里面,opencv前后的*号不要丢掉,懂ubuntu命令的可以大胆的写。
2、重新安装方法:相关的内容网上很多可以自行搜索

卸载重装后,重新编译c++项目,但运行可执行文件时,还是报相同的错误。

忽然想到本地已经安装anaconda,打开spyder后,运行cv2.imshow()时,报错与上相同,就想,干脆通过anaconda重新安装opencv3.4.1。结果就是OK了!!!很激动啊
a.上这里: https://anaconda.org/menpo/opencv3/files 下载对应的opencv。
b.ctrl+alt+T:进入下载好的opencv的路径,输入:conda install opencv3-3.1.0-py35_0.tar.bz2
c.测试:

python
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
cv2.__version __
‘3.1.0’

OK!

你可能感兴趣的:(Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.)