fatal error: No such file or directory

asked 2014-09-02 06:11:53 -0600

rmm gravatar image

I was testing very first program in OpenCV. I am using OpenCV with gcc and CMake. My .cpp file is in folder "G:\OpenCV\myproj\DisplayImage.cpp"

It is as Follow:

include <stdio.h>

include <opencv2 opencv.hpp="">

using namespace cv;

int main(int argc, char** argv ) { if ( argc != 2 ) { printf("usage: DisplayImage.out <image_path>\n"); return -1; }

Mat image;
image = imread( argv[1], 1 );

if ( !image.data )
{
    printf("No image data \n");
    return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);

waitKey(0);

return 0;

} When I compile and run using following command:

g++ -l G:\OpenCV\opencv\sources\release\install\include -L G:\OpenCV\opencv\sources\release\lib DisplayImage.cpp -l opencv_core249 -l opencv_highgui249 -o DisplayImage.out

It gives following error: DisplayImage.cpp:2:30: fatal error: opencv2/opencv.hpp: No such file or directory

include <opencv2 opencv.hpp=""> ^

compilation terminated --Kind suggest me a solution with reason for error

edit retag flag offensive close merge delete

Comments

Please learn compiler basics. The compiler is very clear that it can not find the file where it expects it. You should be able to resolve this on your own. But my guess is it looks like you have used the wrong argument to guide the compiler to the include path. I think it is as simple as using -I (capital i) instead of -l (lower case L).

boaz001 gravatar imageboaz001 ( 2014-09-02 10:53:37 -0600 )edit