我已经按照以下步骤()安装了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是否安装正确。如果您已经安装了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 ..
记得WITH_GTK=ON在cmake期间放。完成此步骤后,输入命令,
make -j$(nproc)
sudo make install
这应该可以解决您的问题。如果您破坏了libgtk2.0-dev的依赖关系,请使用aptitude安装libgtk2.0-dev的新副本。
sudo aptitude install libgtk2.0-dev
遇到无法安装libgtk-3-dev,缺少依赖可以根据提示信息安装相关依赖。
例如:
sudo apt-get install libwayland-egl1=1.18.0-1ubuntu0.1