title: GCC how to add before the default linker search path by default? LIBRARY_PATH not working
body: <p>I'm trying to figure out how to set some environment variable which would make g++ to link to correct versions of the libraries.</p>
  
  <p>I have some old boost libraries in /usr/lib64 (linking against these will fail) and new libraries in /v/users/regel/lib. So the linker should link against the new libraries.</p>
  
  <p>Command:</p>
  
  <pre><code>$ g++ test.cpp -lboost_system -L/v/users/regel/lib
  </code></pre>
  
  <p>links the program correctly. However, I wish to set this as the number 1 search directory for the linker so that I don't have to specify '-L' every time I link.</p>
  
  <p>The following environment variables do not seem to do the trick:</p>
  
  <pre><code>$ LIBRARY_PATH=/v/users/regel/lib g++ test.cpp -lboost_system
  /tmp/regel/cc4SmBtI.o: In function `main':
  test.cpp:(.text+0x5): undefined reference to `boost::system::system_category()'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$ LD_LIBRARY_PATH=/v/users/regel/lib:$LD_LIBRARY_PATH g++ test.cpp -lboost_system
  /tmp/regel/ccUreBZy.o: In function `main':
  test.cpp:(.text+0x5): undefined reference to `boost::system::system_category()'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Despite reading numerous articles and posts on similar subjects, I have not found a solution yet. </p>