title: makefile c++ with other h file dependencies with OpenGL
body: <p>for the life of me I cannot get this to compile properly using a makefile
  I have c++ files that are using OpenGL. </p>
  
  <p>Some files are dependent on others</p>
  
  <p>I have 5 files</p>
  
  <ul>
  <li>main.cpp </li>
  <li>Vector.h </li>
  <li>Vector.cpp </li>
  <li>Utility.cpp </li>
  <li>Utility.h</li>
  </ul>
  
  <p>~ Dependencies ~</p>
  
  <p>IN MAIN.CPP</p>
  
  <pre><code>#include &lt;GL/gl.h&gt;
  #include &lt;GL/glu.h&gt;
  #include &lt;GL/glut.h&gt;
  #include "Vector.h" 
  </code></pre>
  
  <p>IN VECTOR.CPP</p>
  
  <pre><code>#include &lt;GL/gl.h&gt;
  #include &lt;GL/glu.h&gt;
  #include &lt;GL/glut.h&gt;
  #include "Vector.h"
  #include "Utility.h"
  </code></pre>
  
  <p>IN UTILITY.CPP</p>
  
  <pre><code>#include "Utility.h"
  </code></pre>
  
  <p>My after trying and arranging various flags this is what
  the makefile currently looks like</p>
  
  <pre><code>program1: main.o Vector.o Utility.o
      g++ -std=c++11 main.o Vector.o Utility.o -o program1
  main.o: main.cpp Vector.h
      g++ -std=c++11 main.cpp -lglut -lGL -lGLU -lglut -lm
  Vector.o: Vector.cpp Vector.h Utility.h
      g++ -std=c++11 Vector.cpp -lglut -lGL -lGLU -lglut -lm
  Utility.o: Utility.cpp Utility.h
      g++ -std=c++11 Utility.cpp -lglut -lGL -lGLU -lglut -lm
  clean:
      -rm -f *.o
  </code></pre>
  
  <p>Typing "make" outputs the following result:</p>
  
  <pre><code>g++ -std=c++11 main.cpp -lglut -lGL -lGLU -lglut -lm
  g++ -std=c++11 Vector.cpp -lglut -lGL -lGLU -lglut -lm
      /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In (.text+0x20): undefined reference to 'main'
      collect2: error: ld returned 1 exit status
      makefile:6: recipe for target 'Vector.o' failed
      make: ***[Vector.o] Error 1
  </code></pre>
  
  <p>How can I fix my makefile? Thank you</p>