title: gcc: Difference between -L and -l option AND how to provide complete path to a library
body: <p>I am new to makefile stuff; so, please accept my apology if my questions are trivials.</p>
  
  <p><strong>Question 1</strong>: What is the difference between -L and -l option.</p>
  
  <p><strong>Question 2</strong>: How do you provide complete path to some library? For instance, "libeng" and "libmx", mentioned in following makefile,are located at {MATLABROOT}/bin/glnxa64</p>
  
  <pre><code># root directory of MATLAB installation
  MATLABROOT="/usr/local/MATLAB/R2011b"
  
  all: engdemo
  
  engdemo:
      g++ ${MATLABROOT}/extern/examples/eng_mat/engdemo.cpp -o engdemo \
          -I${MATLABROOT}/extern/include \
          -L${MATLABROOT}/extern/lib -llibeng -llibmx
  
  clean:
      rm -f engdemo *.o
  </code></pre>
  
  <p>Update:
  Following makefile works:</p>
  
  <pre><code># root directory of MATLAB installation
  MATLABROOT="/usr/local/MATLAB/R2011b"
  
  all: engdemo
  
  engdemo:
      g++ ${MATLABROOT}/extern/examples/eng_mat/engdemo.cpp -o engdemo \
          -I${MATLABROOT}/extern/include \
          #-L${MATLABROOT}/extern/lib -llibeng -llibmx
      -L${MATLABROOT}/bin/glnxa64 -llibeng \
      -L${MATLABROOT}/bin/glnxa64 -llibmx
  
  clean:
  rm -f engdemo *.o
  </code></pre>
  
  <p>I found following link about linking libraries very useful:
  <a href="http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html" rel="noreferrer">http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html</a></p>