title: How to configure Makefile to use OpenCV
body: <p>I installed opencv in RaspberryPi and configured Makefile but it can't find header files.
  How to configure Makefile correctly?</p>
  <p>I have 2 <code>.cpp</code> files and 1 <code>.h</code> file.</p>
  <pre><code>BlobLabeling.cpp  BlobLabeling.h  hand_tracking.cpp
  </code></pre>
  <p>When I run make, it returns the following:</p>
  <pre><code>pi@raspberrypi ~/test $ make
  g++ BlobLabeling.cpp
  In file included from BlobLabeling.cpp:2:0:
  BlobLabeling.h:9:31: fatal error: highgui/highgui.hpp: No such file or directory
  compilation terminated.
  Makefile:11: recipe for target 'BlobLabeling.o' failed
  make: *** [BlobLabeling.o] Error 1
  </code></pre>
  <hr />
  <p><strong>in BlobLabeling.cpp</strong></p>
  <pre><code>#include &quot;BlobLabeling.h&quot;
  </code></pre>
  <p><strong>in hand_tracking.cpp</strong></p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &quot;cv.h&quot;
  #include &quot;highgui.h&quot;
  #include &quot;BlobLabeling.h&quot;
  </code></pre>
  <p><strong>in BlobLabeling.h</strong></p>
  <pre><code>#include &quot;highgui/highgui.hpp&quot;
  #include &quot;opencv.hpp&quot;
  </code></pre>
  <p><strong>Makefile</strong></p>
  <pre><code>CXX = g++
  
  LDFLAGS = -lopencv_legacy -lopencv_highgui -lopencv_core -lopencv_ml -lopencv_video -lopencv_imgproc -lopencv_calib3d -lopencv_objdetect -L/usr/lib
  
  CPPFLAGS = -g -I/usr/include/opencv -I/usr/include/opencv2
  
  all: BlobLabeling.o hand_tracking.o
          g++ -o test BlobLabeling.o hand_tracking.o
  
  BlobLabeling.o: BlobLabeling.cpp
          g++ BlobLabeling.cpp
  
  hand_tracking.o: hand_tracking.cpp BlobLabeling.h
          g++ hand_tracking.cpp
  </code></pre>
  <p><strong>in /usr/include/opencv2</strong></p>
  <pre><code>pi@raspberrypi ~/test $ ls /usr/include/opencv2
  calib3d  features2d  imgproc  objdetect   stitching  videostab
  contrib  flann       legacy   opencv.hpp  ts
  core     highgui     ml       photo       video
  </code></pre>