title: Specifying order in gcc and g++ include and lib paths
body: <p>I have multiple versions of a library, all with the same name (boost libraries), each installed in its own directory. I know how to instruct the compiler and linker to search in certain directories for header files and libraries (<code>-I</code> and <code>-L</code>). <a href="https://stackoverflow.com/questions/828053/how-do-you-link-to-a-specific-version-of-a-shared-library-in-gcc">I am also aware</a> of how to pass the actual library file to the linker.  </p>
  
  <p>My question is how to specify precedence in the search path of the compiler and the linker, such that it searches folder <code>A</code> before searching folder <code>B</code> and takes <code>A</code>'s version of the library instead of <code>B</code>'s . I'm interested in order between all eligible directories, i.e. the default <code>gcc</code> and <code>g++</code> ones, and the ones specified after <code>-I</code> and <code>-L</code>.  </p>
  
  <p>My distro is Ubuntu <code>14.04</code>, and I use <code>g++</code> <code>4.8</code> up to <code>6</code>.</p>