title: Cross-Compiling for RaspBerry Pi
body: <p>With a RaspBerry Pi and from my computer, I'm trying to cross-compile a simple helloWorld written in C++. I'm using Code Sourcery toolchain for linux to compile.</p>
  
  <p>When copy the helloWorld binary to raspBerry by TFTP and give it execution permissions with chmod, the next error appears:</p>
  
  <p>"Illegal instruction"</p>
  
  <p>If make a 'file' over binary I get:
  "raspberry: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped"</p>
  
  <p>This is because I used "-static -static-libstdc++" when linking.</p>
  
  <p>If I don't use static linking, the error is:
  "Segmentation fault"</p>
  
  <p>The Code:</p>
  
  <pre><code>/*
   * main.cpp
   *
   *  Created on: 26/06/2012
   *      Author: ccortiz
   */
  
  #include &lt;iostream&gt;
  using namespace std;
  
  int main(void){
  
      cout &lt;&lt; "Hello Cross Compilling for ARM!" &lt;&lt; endl &lt;&lt; flush;
      return 0;
  }
  </code></pre>
  
  <p>How could I compile and run my program in a right way?
  Thanks.</p>