Opencv_modules.hpp not generated when building from source

I’m building openCV using the following instructions:


make -j8
sudo make install
sudo ldconfig

The build is successful, but when running a hello world example:

#include "opencv2/opencv.hpp"
int main() {
    cout >> "Hello World";
    return 0;

and compiling it with
gcc -Iopencv/include helloworld.cpp -o hw.exe

I get the following error:

OpenCV/include/opencv2/opencv.hpp:48:10: fatal error: opencv2/opencv_modules.hpp: No such file or directory
   48 | #include "opencv2/opencv_modules.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

My belief is the make commands should be creating an opencv_modules.hpp file tat lays the paths out to the rest of the dependencies, but this file is not being generated in my case. How can I fix this?

  • exact opencv version ?
  • did you run a proper make install ?

looks like it is pointing into the src folder (wrong), not where you installed it.

(proper location for 4.x on linux would be: /usr/local/include/opencv4)

Thanks @berak , you were right. My install was fine, and I expected the files to be generated in the OpenCV source folder itself. Fixed by changing include reference to

1 Like