title: ld64.so present in ldd, missing at runtime
body: <p>I am compiling some code, and for various reasons I'm doing it statically. On my Ubuntu 12.04 / gcc 4.6.3 machine it compiles executes fine, and is fully static:</p>
  
  <pre><code>&gt; ldd mycode
      not a dynamic executable
  </code></pre>
  
  <p>So far so good.
  But I also need to run it on another machine, a Scientific Linux 5 system, running gcc 4.5.3. For some reason here, ldd has some dynamic libs left over:</p>
  
  <pre><code>&gt; ldd mycode
      linux-vdso.so.1 =&gt;  (0x00007fffd75fd000)
      libstdc++.so.6 =&gt; /usr/local/swift/gcc-4.5.3/lib64/libstdc++.so.6 (0x00002b4bafab2000)
      libm.so.6 =&gt; /lib64/libm.so.6 (0x000000398ca00000)
      libc.so.6 =&gt; /lib64/libc.so.6 (0x000000398c600000)
      /lib/ld64.so.1 =&gt; /lib64/ld-linux-x86-64.so.2 (0x000000398c200000)
      libgcc_s.so.1 =&gt; /usr/local/swift/gcc-4.5.3/lib64/libgcc_s.so.1 (0x00002b4bafdb8000)
  </code></pre>
  
  <p>Which is, in itself, fine. The code compiles and links OK, and as you can see from ldd, all the dependencies are resolved. However, when I try to execute it on the SL machine, it fails:</p>
  
  <pre><code>&gt; ./mycode
    /lib/ld64.so.1: bad ELF interpreter: No such file or directory
  </code></pre>
  
  <p>As far as I can see therefore, at execute time for some reason the <code>/lib/ld64.so.1 =&gt; /lib64/ld-linux-x86-64.so.2</code> link is not being resolved, even though ldd does it. Of course, on machines where I have root access I can solve this by making a sym link from ld-linux-x84..blah to /lib/ld64.so.1 but this is a rather pants solution and I can't apply it to our cluster. If I compile the whole thing dynamically it works fine, but this means installing all the 3rd party libraries I'm compiling against on a bunch of machines which I wanted to avoid. Finally, all the dependencies against which I compile are also used by another project, also compiled with cmake, and in that case I have no problem, and ldd  actually lists the /lib64/ld-linux...blah direct, not a call to /lib/ld64.so.</p>
  
  <p>So - why is this happening? Why can I compile and link the code OK, ldd it OK, and yet not execute it? Any ideas would be gratefully received!</p>