c++ - OpenCV GTK+2.x 错误 - "Unspecified error (The function is not implemented...)"

标签 c++ opencv cmake makefile

我已经按照这些步骤安装了 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

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包管理器,运行以下命令:

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。进入这个文件夹。例如,

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 ..

记得在 CMake 期间设置 WITH_GTK=ON

这一步之后,输入命令,

make
sudo make install

这应该可以解决您的问题。如果您损坏了 libgtk2.0-dev 的依赖项,请使用 aptitude 安装新的 libgtk2.0-dev 拷贝。

sudo aptitude install libgtk2.0-dev

关于c++ - OpenCV GTK+2.x 错误 - "Unspecified error (The function is not implemented...)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28776053/

相关文章:

cmake - 使用带有空格的 CMake 的 include_directories 命令

c++ - 眨眼检测 OpenCV C++

opencv - 实现 openCV 方法 warpPerspective()

c++ - 在 OS X 上使用 Boost Python 和 CMake

无法通过 cmake : Cannot open include file: 'zlib.h' : No such file or directory 在 Windows 上编译 libpng 1.6

android - 如何将位图图像转换为mat图像

c++ - 使用 DMA 与 PCIe 通信

c++ - C++ 中的 long long int 与 long int 与 int64_t

C++复制字符串文字(来自C)

opencv - 使用OpenCV显示网络摄像头