# Imshow() throws: The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support

**URL:** <https://forum.opencv.org/t/imshow-throws-the-function-is-not-implemented-rebuild-the-library-with-windows-gtk-2-x-or-cocoa-support/13259>\
**Category:** C++\
**Tags:** highgui, build, cmake, gtk\
**Created:** [May 21, 2023, 11:28pm UTC](https://forum.opencv.org/t/imshow-throws-the-function-is-not-implemented-rebuild-the-library-with-windows-gtk-2-x-or-cocoa-support/13259 "2023-05-21T23:28:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![patil\_dushyant](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/patil_dushyant/32/7926_2.png) [@patil\_dushyant](https://forum.opencv.org/u/patil_dushyant)\
**Post date:** [May 21, 2023, 11:28pm UTC](https://forum.opencv.org/t/imshow-throws-the-function-is-not-implemented-rebuild-the-library-with-windows-gtk-2-x-or-cocoa-support/13259/1 "2023-05-21T23:28:06Z")

</div>

I have installed opencv from scratch and included opencv contrib to extra modules path. After this, I wrote basic script to read and show an image and compiled the code using cmake. The compilation was successful but when I tried to run the executable, I get following error:

```auto
terminate called after throwing an instance of 'cv::Exception'
  what(): OpenCV(4.7.0-dev) /home/dushyant/Documents/cpp/opencv_scratch/opencv-4.x/modules/highgui/src/window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

Aborted (core dumped)

```

My code is as follows:

```auto
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/features2d.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
#include<cmath>
using namespace cv;
using namespace std;
using namespace xfeatures2d;

int main(int argc, char** argv)
{
    Mat img1, img2;
    img1 = imread("../1.jpg");
    img2 = imread("../2.jpg");
    imshow("Keypoints", img1);
    waitKey(0);
return(0)}

```

My `CMakeList.txt` is as follows:

```auto
cmake_minimum_required(VERSION 3.8)
project(DisplayIm)

find_package(OpenCV REQUIRED)
set(OPENCV_ENABLE_NONFREE ON)

if(OPENCV_XFEATURES2D_FOUND)
    message("xfeatures2d found")
else()
    message("xfeatures2d not found")
endif()
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(DisplayImage DisplayImage.cpp)
add_executable(Pano pano.cpp)
add_executable(KP sift_kp.cpp)
target_link_libraries(Pano ${OpenCV_LIBS})
target_link_libraries(DisplayImage ${OpenCV_LIBS})
target_link_libraries(KP ${OpenCV_LIBS})

```

When I check if I have libgtk in system using locate libgtk, I see `libgtk-3-dev` and `libgtk2.0-dev` files along with lots of other libgtk files. What should I do to run this basic code? What do I need to learn about build systems that will make it easier to solve such errors?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 21, 2023, 11:37pm UTC](https://forum.opencv.org/t/imshow-throws-the-function-is-not-implemented-rebuild-the-library-with-windows-gtk-2-x-or-cocoa-support/13259/2 "2023-05-21T23:37:48Z")

</div>

[crosspost](https://meta.stackoverflow.com/a/266159):

> <https://stackoverflow.com/questions/76302012/cvimshow-error-terminate-called-after-throwing-an-instance-of-cvexception>

---

<div class="post-metadata">

**Author:** ![patil\_dushyant](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/patil_dushyant/32/7926_2.png) [@patil\_dushyant](https://forum.opencv.org/u/patil_dushyant)\
**Post date:** [May 21, 2023, 11:39pm UTC](https://forum.opencv.org/t/imshow-throws-the-function-is-not-implemented-rebuild-the-library-with-windows-gtk-2-x-or-cocoa-support/13259/3 "2023-05-21T23:39:45Z")

</div>

@crackwitz Can you guide me on this matter. The [crosspost](https://meta.stackoverflow.com/a/266159) which you have linked does not have the answer on solving this issue
