I am trying to get an OpenCV hello world program to work using the nix package manager but its spewing out errors :
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 /tmp/nix-build-opencv-2.4.13.drv-0/opencv-2.4.13-src/modules/highgui/src/window.cpp, line 483 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/nix-build-opencv-2.4.13.drv-0/opencv-2.4.13-src/modules/highgui/src/window.cpp:483: 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
I used the following default.nix file to create a nix-shell
with import <nixpkgs> {}; {
cimgEnv = stdenv.mkDerivation {
name = "cimgdev";
buildInputs = [ pkgconfig stdenv cimg xorg.libX11 boost opencv gnome.gtk ];
};
}
to compile and run the following code
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main() {
Mat image;
image = imread("lena.jpg", 1);
if ( !image.data ) {
cout << "No image data" << endl;
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE);
imshow("Display Image", image);
waitKey(0);
return 0;
}
using the following command
g++ `pkg-config --cflags opencv` opencvtest.cpp `pkg-config --libs opencv` -o opencvtest
It compiles, but if I try to run it, I get the previous error message.
I tried CMake, with the same outcome.