title: Include header file in different directory in c++
body: <p>I've been learning c++ and encountered the following question:
  I have a directory structure like:</p>
  
  <pre><code> - current directory
  
    - Makefile
  
    - include
  
       - header.h
  
    - src
  
        - main.cpp
  </code></pre>
  
  <p><strong>my header.h :</strong></p>
  
  <pre><code>#include &lt;iostream&gt; 
  
  using namespace std;
  
  void print_hello();
  </code></pre>
  
  <p><strong>my main.cpp:</strong></p>
  
  <pre><code>#include "header.h"
  
  int main(int argc, char const *argv[])
  {
      print_hello();
      return 0;
  }
  
  void print_hello()
  {
      cout&lt;&lt;"hello world"&lt;&lt;endl;
  }
  </code></pre>
  
  <p><strong>my Makefile:</strong></p>
  
  <pre><code>CC = g++
  OBJ = main.o
  HEADER = include/header.h 
  CFLAGS = -c -Wall 
  
  hello: $(OBJ) 
      $(CC) $(OBJ) -o $@
  
  main.o: src/main.cpp $(HEADER)
      $(CC) $(CFLAGS) $&lt; -o $@
  
  clean: 
      rm -rf *o hello
  </code></pre>
  
  <p>And the output of make is:</p>
  
  <blockquote>
    <p>g++ -c -Wall  src/main.cpp -o main.o
    src/main.cpp:1:20: fatal error: header.h: No such file or directory
    compilation terminated.
    Makefile:10: recipe for target 'main.o' failed
    make: *** [main.o] Error 1</p>
  </blockquote>
  
  <p>What mistakes I have made in here. It's frustrating. Really appreciate any advice!</p>