With a Raspberry Pi and from my computer, I'm trying to cross-compile a simple helloWorld written in C++. I'm using the Code Sourcery toolchain for Linux to compile.
When copying the helloWorld binary to the Pi by TFTP and giving it execution permissions with chmod, the next error appears:
"Illegal instruction"
If I make a 'file' over binary I get:
raspberry: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped
This is because I used -static -static-libstdc++
when linking.
If I don't use static linking, the error is: "Segmentation fault"
The Code:
#include <iostream>
using namespace std;
int main(void){
cout << "Hello Cross Compiling for ARM!" << endl << flush;
return 0;
}
How could I compile and run my program in the right way?
endl
alreadyflush
es, so you deliberately flush twice. This is why I prefer using'\n'
toendl
in the first place. – Clue