1

I made the ~/.compile_opencv.sh as given https://help.ubuntu.com/community/OpenCV on this website and then I made this file opencvtest.cpp with the following contents . The image path is a valid path .

#include <opencv2/highgui/highgui.hpp>
using namespace cv;

int main() {
  Mat img = imread("/home/AbKDs/Desktop/friends.jpg",CV_LOAD_IMAGE_COLOR);
  imshow("opencvtest",img);
  waitKey(0);

  return 0;
}

I have created the alias opencv="~/.compile_opencv.sh". But when I run it shows the following error .

bash: /home/AbKDs/.compile_opencv.sh: Permission denied

Instead of this I tried the whole command but even then it shows fatal error .

opencvtest.cpp:1:39: fatal error: opencv2/highgui/highgui.hpp: No such file or directory
 #include <opencv2/highgui/highgui.hpp>
                                       ^
compilation terminated.

Please help . Thanks in advance

abkds
  • 615

1 Answers1

7

Well, the error message is pretty clear, right?

fatal error: opencv2/highgui/highgui.hpp: No such file or directory

You'll have to install the development package of opencv-highgui (libopencv-highgui-dev) in order to install the required opencv2/highgui/highgui.hpp header file.

Rather than providing you fish, here's teaching you how to fish (similar to https://askubuntu.com/a/219539/88802).

  1. Determine the missing file. In this case: highgui.hpp

  2. Search for what package provides the file, e.g. via http://packages.ubuntu.com or using apt-file.

    In this case: http://packages.ubuntu.com/search?searchon=contents&keywords=highgui.hpp&mode=exactfilename&suite=trusty&arch=any

  3. Install the package providing the file. In this case:

    sudo apt-get install libopencv-highgui-dev
    
  4. Recompile.

gertvdijk
  • 69,427