title: C - how to include own headers kept in separate folder
body: <p>First of all I am pretty much a beginner, so I am not sure how to explain what I need but I'll give it a try. (I searched but couldn't find a complete answer).</p>
  
  <p>I am learning C on my own and using Code Blocks.</p>
  
  <p>I want to create my own mini-library of custom functions to use in my programs.</p>
  
  <p>I have a folder called "C". Inside "C", I have a folder called "Exercises" where I do all the little projects from a book.</p>
  
  <p>Also inside "C", I wanna have another folder called "MyC" in which I would keep my own header files and the .c files containing the implementations of my custom functions.
  For example, these .h and .c would be saved in "MyC":</p>
  
  <p>//test.h</p>
  
  <pre><code>#ifndef _TEST_H
  #define _TEST_H
  
  int mySum(int, int);
  
  #endif // _TEST_H
  </code></pre>
  
  <p>//test.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "test.h"
  
  int mySum(int a, int b)
  {
      return a + b;
  }
  </code></pre>
  
  <p>So now, what I'm trying to do is to be able to create a new project in "Exercises" and not having to bring a copy of both test.h and test.c into the project, but instead just #include my test.h and do something like:</p>
  
  <p>//testMain.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;test.h&gt;
  
  int main(void)
  {
      printf("\n2 + 1 = %d", mySum(2, 1));
  
      return 0;
  }
  </code></pre>
  
  <p>I know that &lt;> are for the standard headers, but quotes are for headers in the current folder, and that's what I don't want.</p>
  
  <p>Is it possible to do this? How?</p>
  
  <p>I've read about going into settings>compiler and on Search Directories add the path where I have the header but didn't work. It gives me an error "undefined reference to 'mySum'"
  I tried quotes and brackets on the #include.</p>
  
  <p>Can you guys please give a step-by-step for what it needs to be done to be able to do this?</p>