I have a self-written programm which I want to build also for Raspberry Pi from my x86 machine. I'm using eclipse generated makefiles and cannot change this thing.
I've read this tutorial for CC for raspi : Hackaday-Link. Because raspi also have installed gcc version 4.9, I also try it with this version of the cross compiler. The problem also exisits with this hello world programm:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "hello world!" << endl;
}
When compiling and running it directly on the raspi, the output is hello world!
. OK, thats fine.
But when cross-compiling it with version 4.9 of arm-linux-gnueabihf-g++-4.9
, then scp it to the raspi, make it executable and run it, the output of ./hello_world
is Segmentation fault
. When executing sudo ./hello_world
there is no output.
I tried to get some information about the files and see that the locally on the raspi compiled program outputed:
pi@raspberrypi:~ $ file hello_world
hello_world: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=41161ae762d940b12c3313ca065a3badd284f6d3, not stripped
and the cross-compiled version outputs
pi@raspberrypi:~ $ file hello_world
hello_world: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=4f1f4fb86710ef8130f148dc5adae1c0c18092fd, not stripped
Can anyone tell me what the problem is and how to solve it?