title: How to fix "fatal error: opencv2/core.hpp: No such file or directory" for opencv4 installed in manjaro
body: <p>Essentially, I've been able to install openCV fine for python but I also want to be able to do it for C++. I was able to install it using my linux distro's package manager (pacman for manjaro which is based on arch) but I haven't gotten the following program to work to test openCV</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;opencv2/core.hpp&gt;
  
  int main() {
     std::cout &lt;&lt; "OpenCV version: " &lt;&lt; CV_VERSION &lt;&lt; std::endl;
     return 0;
  }
  </code></pre>
  
  <p>The error I get from trying to compile this program is the following:</p>
  
  <pre><code>cv.cpp:2:10: fatal error: opencv2/core.hpp: No such file or directory
      2 | #include &lt;opencv2/core.hpp&gt;
        |          ^~~~~~~~~~~~~~~~~~
   compilation terminated.
  </code></pre>
  
  <p>Apparently, this is a common error, however I have tried many solutions and they all seem to not work. I know where core.hpp is and it is actually at /usr/local/include/opencv4/opencv2/core.hpp. However, when I change the include statement to</p>
  
  <pre><code> #include opencv4/opencv2/core.hpp
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code> In file included from cv.cpp:2:
   /usr/include/opencv4/opencv2/core.hpp:52:10: fatal error: opencv2/core                /cvdef.h: No such file or directory
     52 | #include "opencv2/core/cvdef.h"
        |          ^~~~~~~~~~~~~~~~~~~~~~
   compilation terminated.
  </code></pre>
  
  <p>Indicating that all the header files path directories are wrong essentially. I tried to fix this with the following symbolic link but that didn't work either:</p>
  
  <pre><code>$ sudo ln -s /usr/local/include/opencv4/opencv2/ /usr/local/include/opencv2
  </code></pre>
  
  <p>I also tried compiling in the following way:</p>
  
  <pre><code>$ g++ -o cv cv.cpp -I/usr/local/include/opencv4 -Lusr/local/lib -lopencv_core
  </code></pre>
  
  <p>That also didn't work and gave me the same errors. For reference, this is how I compiled before:</p>
  
  <pre><code>$ g++ cv.cpp -o cv
  </code></pre>
  
  <p>I also don't know if this means anything, but</p>
  
  <pre><code>$ pkg-config --libs opencv4
  </code></pre>
  
  <p>gives me the following results:</p>
  
  <pre><code>-lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm     -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_viz -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core 
  </code></pre>
  
  <p>Although I have no idea what this means nor do I know if this helps me at all. I'd rather not have any other indirect solutions. Any ideas on how to fix this?</p>