title: Why isn't DYLD_LIBRARY_PATH being propagated here?
body: <p>I have a simple C++ program that I'm trying to run that is linked against a version of the Boost.Thread library that I built previously. I seem to be having trouble understanding the way that runtime library paths behave on OS X. </p>
  
  <p>Since my Boost library doesn't have an <a href="https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html" rel="noreferrer">RPATH-relative install name</a>, I'm using the <code>DYLD_LIBRARY_PATH</code> environment variable to tell the dynamic linker where to find <code>libboost_thread.dylib</code> at runtime.</p>
  
  <p>This works fine if I run the program directly in my (<code>bash</code>) shell:</p>
  
  <pre><code>[~/git/project]$ echo $DYLD_LIBRARY_PATH
  /Users/jasonr/git/project/boost/lib
  [~/git/project]$ .sconf_temp/conftest_7
  [~/git/project]$ # Program runs successfully; this is what I expect.
  </code></pre>
  
  <p>However, this program is run as part of a series of tests by an <code>autoconf</code>-like framework that I'm using. It runs the program in a child shell using <code>sh -c</code>. Here's what happens if I try that:</p>
  
  <pre><code>[~/git/project]$ # Make sure the environment variable is exported to child shells.
  [~/git/project]$ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
  [~/git/project]$ # Try to run it in a child shell.
  [~/git/project]$ sh -c .sconf_temp/conftest_7
  dyld: Library not loaded: libboost_thread.dylib
    Referenced from: /Users/jasonr/git/project/.sconf_temp/conftest_7
    Reason: image not found
  Trace/BPT trap: 5
  </code></pre>
  
  <p>It's as if the environment variable isn't propagated to <code>dyld</code> in this case. Why would this occur? I'm more familiar with the behavior of <code>LD_LIBRARY_PATH</code> on Linux, which (I think) should work with the above example. Is there something else I need to do in order to make this work?</p>