How to link and use OpenCV headers?

19,262

The best way to manage changing directories for include files is with the compiler options. Im better at linux and g++, where you would just specify different include path locations with -I attributes.

Its generally considered bad practice to use relative and absolute paths in the #include statements. Module paths are ok #include <sys/time.h>, where sys could be considered the module. Include the file with just its name and possibly the module, then handle the location with the compiler options.

Share:
19,262
Danny
Author by

Danny

A student learning about game programming and development

Updated on June 04, 2022

Comments

  • Danny
    Danny almost 2 years

    Right, I know this is a very stupid question, but I have no luck with w/e i'm trying to do.

    I'm trying to use the objdetect.hpp header file, so I've included the folder C:\OpenCV2.1\include\opencv2\ aswell as C:\OpenCV2.1\include\opencv and a whole bunch of other libraries and dlls when I was following the instructions on http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010

    But the openCV version in that tutorial were outdated and doesn't even have the objdetect.hpp file. So I went to download the latest one (OpenCV 2.4.0), but now when I complie it, it gives me an error C1083: Cannot open include file: "opencv2/core/core.hpp" No such file directory.

    Am I suppost to put all the OpenCV folders/files in the same directory as my C++ project? Or how do I fix it? I've tried putting it in the same place as my C++ project, but when I do a #include "../" the folder doesn't appear.

    Again, I know this is a stupid question, but please help.

    Let me know if anyone require more info coz I'm not too sure whatelse to put.

    Thanks