title: How do I run a C program that involves an external library in a PHP script?
body: <p>I created a simple C program that takes an integer argument and outputs that integer plus two. I can run it in a terminal with </p>
  
  <p><code>./simplep 2</code> </p>
  
  <p>and in PHP with </p>
  
  <p><code>exec('./simplep 2', $output)</code>.</p>
  
  <p>I have a more complicated program called <code>myprogram</code> which involves an external library. I can run it in the terminal with </p>
  
  <p><code>./myprogram a.mov</code></p>
  
  <p>but it fails if I run it in PHP with </p>
  
  <p><code>exec('./myprogram a.mov', $output)</code></p>
  
  <p>No output is produced, which makes me think the program isn't running at all. </p>
  
  <p>PS. I am working on Mac.</p>
  
  <p><strong>update</strong></p>
  
  <p>From the error ouput I know the problem is the library. It says </p>
  
  <pre><code>dyld: Library not loaded: /opt/local/lib/libjpeg.8.dylib". 
  </code></pre>
  
  <p>But the library file is there.</p>