title: Cross Compile helloworld for ARM
body: <p>I'm trying a simple cross compile (cc) for an ARM-CORTEX-A9:
  To keep things simple thats the c-code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
     printf("Hello World!\n");
     return 0;
  }
  </code></pre>
  
  <p>The native compilation on the arm works fine and is started with <code>gcc helloworld.c -o helloworld</code> whereas the cross compile is started with <code>arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc</code></p>
  
  <p><strong><em>GCC Version:</em></strong></p>
  
  <p>nativ: <code>gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) Target: arm-linux-gnueabihf</code></p>
  
  <p>CC: <code>gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-79) Target: arm-xilinx-linux-gnueabi</code></p>
  
  <p><strong><em>ABI from readelf:</em></strong></p>
  
  <p>readelf-nativ: <code>OS: Linux, ABI: 2.6.31</code>
  readelf-cc: <code>OS: Linux, ABI: 2.6.16</code></p>
  
  <p><strong><em>Linked libs</em></strong> - the cross compiled is statically linked so it shouldn't miss any libs:</p>
  
  <pre><code>root@localhost:/temp# ldd helloworld
          libc.so.6 =&gt; /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ed8000)
          /lib/ld-linux-armhf.so.3 (0xb6fce000)
  root@localhost:/temp# ldd helloworld_cc
          not a dynamic executable
  </code></pre>
  
  <p><strong><em>The Problem:</em></strong> the native program runs fine, the cc always ends up with:</p>
  
  <pre><code>root@localhost:/tmp# ./helloworld_cc
  -bash: ./helloworld_cc: No such file or directory
  </code></pre>
  
  <p>Any hints, hopefully, I have included enough information.</p>
  
  <p><strong>edit</strong></p>
  
  <p>Linking it static does the trick, but now the size of the file is huge (678kB (CC-static) vs. 4kB(native)? Why is it missing libs even if it says it is not dynamically linked? Similar question: <a href="https://stackoverflow.com/questions/9324772/cross-compiling-static-c-hello-world-for-android-using-arm-linux-gnueabi-gcc">Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc</a></p>
  
  <pre><code>arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc -static
  </code></pre>