title: G++ Add include and linking path
body: <h1>My Problem</h1>
  
  <p>I read somewhere that to add include paths to g++ you need to use the <code>-I</code> option:</p>
  
  <p><code>g++ -I /some/directory and_then_my_files.cpp</code></p>
  
  <p>However, I'm not sure if this is actually what I need. It's currently not working for me, and I couldn't find anything else close to what I have.</p>
  
  <h1>My Setup</h1>
  
  <p>I've got a directory with all my current project code, and in it a subdirectory <code>classes</code>, that contains various <code>.h</code> and <code>.cpp</code> files containing classes that may or may not be used when compiling my main files.</p>
  
  <p>Since <code>g++ ./classes/*.cpp main.cpp</code> takes a long time (large number of files in <code>classes</code> directory), I'm looking for an alternative that only compiles and links the files that are included in the main file.</p>
  
  <p>Main file:</p>
  
  <pre><code>#include "classes/a.h"
  #include "classes/b.h"
  // ... my code
  </code></pre>
  
  <p>And as you can imagine, g++ complains about undefined references to classes A and B, unless I add <code>./classes/*.cpp</code> to the build command.</p>
  
  <h1>What I want to achieve</h1>
  
  <p>So <code>-I</code> and <code>-L</code> did not work, and adding the whole directory to the build command results in a ridiculously long build time - I'm talking 3-5 minutes, which really slows down my development speed.</p>
  
  <p>Is there any way to only build/link the included classes from my <code>classes</code> directory, such as only classes A and B from the example I gave above?</p>
  
  <h2>Small Recap of what I've already tried</h2>
  
  <p><code>g++ -I ./classes main.cpp -o main</code></p>
  
  <p><code>g++ -L ./classes main.cpp -o main</code> (probably stupid but I tried it anyway)</p>
  
  <p><code>g++ ./classes/*.cpp main.cpp -o main</code> (what I currently have to resort to)</p>
  
  <hr>
  
  <p><strong>Thanks in advance :)</strong></p>