title: How can I fix my OpenCV4 installation on Ubuntu
body: <p>I need some help. I want to install Opencv4 on my computer (which runs on Ubuntu) and use it with VSCode.</p>
  <p>A lot of tutorial explains how to do it, so here is one of thoses I followed: <a href="https://vitux.com/opencv_ubuntu/" rel="nofollow noreferrer">https://vitux.com/opencv_ubuntu/</a></p>
  <p>I, next, took a program my teacher sent me to check installation:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;opencv4/opencv2/highgui.hpp&gt;
  
  using namespace cv;
  using namespace std;
  
  int main(void)
  {
      string imageName(&quot;/home/baptiste/Documents/M1/infographie/images/lena.jpg&quot;); // path to the image
  
      Mat img;
      img = imread(imageName, IMREAD_COLOR); // Read the file as a color image
      if( img.empty() )                      // Check for invalid input
      {
          cout &lt;&lt;  &quot;Could not open or find the image&quot; &lt;&lt; std::endl ;
          return -1;
      }
  
      Mat img_gray;
  
      img_gray = imread(imageName,IMREAD_GRAYSCALE); //Read the file as a grayscale image
      if( img_gray.empty() )                      // Check for invalid input
      {
          cout &lt;&lt;  &quot;Could not open or find the image&quot; &lt;&lt; std::endl ;
          return -1;
      }
  
      imshow( &quot;Image read&quot;, img );                // Show our color image inside the window.
  
      imshow(&quot;Grayscale image read&quot;, img_gray); //Show our grayscale image inside the window.
  
      waitKey(0); // Wait for a keystroke in the window
      imwrite(&quot;/home/baptiste/Documents/M1/infographie/images/lena_gray.jpg&quot;, img_gray); //Save our grayscale image into the file
      return 0;
  }
  </code></pre>
  <p>I also wrote a makefile:</p>
  <pre><code>CC=g++
  
  read_image: read_image.cpp
      $(CC) read_image.cpp -o read_image `pkg-config --libs --cflags opencv4`
  
  clean:
      rm -f read_image
  </code></pre>
  <p>But when I am compiling, I got this:</p>
  <pre><code>g++ read_image.cpp -o read_image `pkg-config --libs --cflags opencv4`
  In file included from read_image.cpp:3:
  /usr/local/include/opencv4/opencv2/highgui.hpp:46:10: fatal error: opencv2/core.hpp: Aucun fichier ou dossier de ce type
     46 | #include &quot;opencv2/core.hpp&quot;
        |          ^~~~~~~~~~~~~~~~~~
  compilation terminated.
  make: *** [makefile:4 : read_image] Erreur 1
  </code></pre>
  <p>I also spot a problem with my opencv installation: in /usr/local/include, I have a <em>opencv4</em> folder, which contains...a <em>opencv2</em> folder, and then the whole installation.</p>
  <p>I am interpreting this as: the inclusion made by the modules are not reading at the good place. My program actually recognize the location of <em>highgui.hpp</em>, but that module does not recognize the good location for <em>core.hpp</em></p>
  <p>I did not saw anyone having that problem so it might be quite weird but can someone help me with that ?</p>
  <p>Also, I added <code>&quot;/usr/local/include/opencv4/**&quot;</code> into my VSCode configuration.</p>
  <p>Thank you for your answer, and for the time you will invest.</p>
  <p>EDIT 1:
  Here is my c_cpp_properties.json:</p>
  <pre><code>    &quot;configurations&quot;: [
          {
              &quot;name&quot;: &quot;Linux&quot;,
              &quot;includePath&quot;: [
                  &quot;${workspaceFolder}/**&quot;,
                  &quot;/usr/local/include/opencv4/**&quot;
              ],
              &quot;defines&quot;: [],
              &quot;compilerPath&quot;: &quot;/usr/bin/clang&quot;,
              &quot;cStandard&quot;: &quot;c11&quot;,
              &quot;cppStandard&quot;: &quot;c++14&quot;,
              &quot;intelliSenseMode&quot;: &quot;linux-clang-x64&quot;
          }
      ],
      &quot;version&quot;: 4
  }
  </code></pre>
  <p>And how do I the &quot;tasks.json&quot; file ?</p>