OpenCV GTK + 2.x错误 [英] OpenCV GTK+2.x error
问题描述
我已按照以下步骤安装OpenCV()。
在尝试编译一个例子后,我得到这个错误:
I had installed OpenCV following these steps (). After trying to compile one examples,i got this error :
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
CMakeLists.txt
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.4)
project(threadTest)
find_package( OpenCV REQUIRED )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pthread")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/nick/ClionProjects/threadTest")
set(SOURCE_FILES main.cpp)
add_executable(threadTest ${SOURCE_FILES})
target_link_libraries( threadTest ${OpenCV_LIBS} )
如何解决?
推荐答案
首先检查libgtk2.0-dev是否正确安装。如果您安装了aptitude软件包管理器,请运行以下命令:
First check whether libgtk2.0-dev is installed properly. If you have installed aptitude package manager, run the following:
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
您需要再次构建文件。找到您的OpenCV文件夹。创建一个新文件夹并将其命名为release。输入到此文件夹。例如
You need to build the files once again.Locate your OpenCV folder. Create a new folder and name it as release. Enter into this folder. For example
cd /home/user_name/OpenCv
mkdir Release
cd Release
现在使用cmake创建命令如下:
Now build using cmake with following command:
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 ..
code> WITH_GTK = ON 。
此步骤后输入命令
Remember to put WITH_GTK=ON
during cmake.
After this step enter the command,
make
sudo make install
这应该可以解决你的问题。如果libgtk2.0-dev的依赖关系已经破坏,请安装libgtk2.0- dev使用aptitude。
This should resolve your problem.If you have broken dependencies for libgtk2.0-dev, then install a fresh copy of libgtk2.0-dev using aptitude.
sudo aptitude install libgtk2.0-dev
这篇关于OpenCV GTK + 2.x错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!