Ask Your Question
0

opencv.hpp not in /opencv2

asked 2013-06-05 09:35:01 -0600

deepak t s gravatar image

hi all I followed a tutorial "The OpenCV Tutorials, Release 2.4.5.0" and tried to build opencv for linux i could successfully build a /release but the folder /release/opencv2/ does not contain any of the .hpp files except opencv_modules.hpp file i created a sample folder in /release directory /release/sample and pleaced a file : DisplayImage.cpp containg following code :

#include <stdio.h>
#include "../opencv2/opencv.hpp"
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}

//---------------------------- and CMakeLists.txt containing :

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )

//------------------- when i ran cmake . i got

-- Configuring done -- Generating done -- Build files have been written to: /home/student/Documents/openCV/opencv/release/sample

//------------------- when i ran make command i got

100%] Building CXX object
> CMakeFiles/DisplayImage.dir/DisplayImage.cpp.o
> /home/student/Documents/openCV/opencv/release/sample/DisplayImage.cpp:2:30:
> fatal error: opencv2/opencv.hpp: No
> such file or directory compilation
> terminated. make[2]: ***
> [CMakeFiles/DisplayImage.dir/DisplayImage.cpp.o]
> Error 1 make[1]: ***
> [CMakeFiles/DisplayImage.dir/all]
> Error 2 make: *** [all] Error 2

//---------------------- suggestion are welcome

thankyou
deepak

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2013-06-05 13:19:02 -0600

HD_Mouse gravatar image

updated 2013-06-05 13:22:24 -0600

Your line

#include "../opencv2/opencv.hpp"

is specifying a relative path for #include to look. If it can't find it there, then it tries to look for it wherever it stores the standard header files (such as: iostream, stdio.h). Assuming you built OpenCV for linux properly, the headers get copied into /usr/include/. You'll likely find opencv.hpp at "/usr/include/opencv2/opencv.hpp". The line isn't working because of the ".." you added to it. It's causing it to look for a file at /usr/opencv2/opencv.hpp".

You can probably fix this by just replacing that line with this:

#include <opencv2/opencv.hpp>

That said, it would be better practice to pull in only headers that are needed, such as:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-05 09:35:01 -0600

Seen: 44,002 times

Last updated: Jun 05 '13