title: how to use makefile to include .a static library and .h file from another directory in C?
body: <p>I have created a <code>.h</code> header file, implemented and created <code>.a</code> static library file, both of them are in directory in say, <code>/home/data/folder1</code>. </p>
  
  <p>I have another <code>.c</code> file which will use link the <code>.h</code> header file and the <code>.a</code> library file. However, the <code>.c</code> file is in directory <code>/home/data/folder2</code>. </p>
  
  <p>What should I write in the Makefile (which is also located in <code>/home/data/folder2</code>)? Also, should I include <code>myheader.h</code> in the <code>.c</code> file that I want to compile? Here is what I have so far, but not working: </p>
  
  <pre><code>LIBB = -L/home/data/folder1/libmylib.a
  
  HEADER = -L/home/data/folder2/myheader.h
  
  main: main.o
      gcc $(HEADER) $(LIBB) $&lt; -o $@
  
  main.o: main.c
      gcc -c main.c
  
  .PHONY: clean
  
  clean:
  
      rm -f *.o *.~ a.out main
  </code></pre>
  
  <p>Any help will be appreciated, thanks in advance! </p>