title: gcc on Mac OS X: how to link libraries installed with MacPorts?
body: <p>I have installed gcc 4.6 using macports. The prefix is <code>/opt/local</code>, and I get the expected include path:</p>
  
  <pre><code>#include "..." search starts here:
  #include &lt;...&gt; search starts here:  
  /opt/local/include/gcc46/c++/  
  /opt/local/include/gcc46/c++//x86_64-apple-darwin10  
  /opt/local/include/gcc46/c++//backward  
  /opt/local/lib/gcc46/gcc/x86_64-apple-darwin10/4.6.1/include  
  /opt/local/include  
  /opt/local/lib/gcc46/gcc/x86_64-apple-darwin10/4.6.1/include-fixed  
  /usr/include  
  /System/Library/Frameworks  
  /Library/Frameworks End of search list.
  </code></pre>
  
  <p>However, <code>/opt/local/lib</code> doesn't seem to be in the library search path, so I have to specify it with <code>-L/opt/local/lib</code> when using g++ on command line:</p>
  
  <pre><code>Library search paths:
      /opt/local/lib/gcc46/gcc/x86_64-apple-darwin10/4.6.1
      /opt/local/lib/gcc46
      /usr/lib
      /usr/local/lib
  Framework search paths:
      /Library/Frameworks/
      /System/Library/Frameworks/
  </code></pre>
  
  <p>This is a problem for other libraries installed with macports. Is there an easy way to add <code>/opt/local/lib</code> to the library search path? I have tried setting <code>DYLD_LIBRARY_PATH</code> to no avail. I am using Mac OS X 10.6.8.</p>