title: Including header file from static library
body: <p>I am making a test setup of a C static library and program.
  The library code, located in a subdirectory 'foo' of my project, contains the following files:</p>
  
  <p><strong>foo/foo.c:</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  void foo(void) {
      printf("something");
  }
  </code></pre>
  
  <p><strong>foo/foo.h:</strong></p>
  
  <pre><code>#ifndef foo_h__
  #define foo_h__
  extern void foo(void);
  #endif
  </code></pre>
  
  <p>My progam code is as follows:</p>
  
  <p><strong>test.c:</strong></p>
  
  <pre><code>#include "foo.h"
  int main() {
      foo();
      return 0;
  }
  </code></pre>
  
  <p>I have a build script, called 'build', which contains the following:</p>
  
  <p><strong>build:</strong></p>
  
  <pre><code>#!/bin/bash
  gcc -c -Wall -Werror foo/foo.c
  ar rcs libfoo.a foo.o
  gcc -static -o test test.c libfoo.a # I have also tried -L. -lfoo
  </code></pre>
  
  <p>But when I run build, it gives me the following error:</p>
  
  <pre><code>test.c:1:17: fatal error: foo.h: No such file or directory
    #include "foo.h"
                    ^
  Compilation terminated
  </code></pre>
  
  <p>It does, however, work when I omit the #include line, but I would prefer if I could use header files in my static libraries. What am I doing wrong, and how can I fix it?</p>