title: Telling ld where to look for directories via an environment variable
body: <p>I'm grading C and C++ files for a class, and this assignment uses the GSL library.  Since I don't have root permission on my computer, my GSL library is installed in my home directory, and thus I need to tell compilers and linkers where to find it.</p>
  
  <p>This isn't a problem when I write a program myself, because I just add the appropriate -L and -I flags to gcc.</p>
  
  <p>But when I'm compiling student's files, I don't want to edit every one of their makefiles.  Instead, I want to put the appropriate directories into an environment variable, so that it happens seamlessly.</p>
  
  <p>To this end, I've exported the following variables with the library or include locations:
  C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,  LIBRARY_PATH and  LD_LIBRARY_PATH</p>
  
  <p>But when I compile a student's project, with</p>
  
  <pre><code>gcc -Wall -o MC_thread MC_thread.c -lgsl -lgslcblas -lpthread -lm
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>/usr/bin/ld: cannot find -lgsl
  collect2: ld returned 1 exit status
  make: *** [all] Error 1
  </code></pre>
  
  <p>I'm using gcc v 4.1.2.  I actually don't get the error if I use gcc v 4.4, but I have no clue why.  My linker is: </p>
  
  <pre><code>ld -V
  GNU ld version 2.17.50.0.6-12.el5 20061020.
  </code></pre>