I have this simple program with its sources in a 'src' folder and the includes in the 'inc' folder. Normally i compile this with:
gcc -I../inc *.c
This leaves 'a.out' as program which works fine on that pc.
But how do i compile this for my BeagleBone Black (ARM)? With this i am thinking about:
gcc (some arguments to crosscompile for arm) -I../inc *.c
If you’re looking for ‘Hello, World!’ for 32-bit ARM, check out my previous post: ‘Hello World’ in ARM Assembly. The structure of a minimal ‘Hello World!’ Our aim is to translate the following ‘Hello, World!’ C app to ARM64 assembly:
To build, I’ll use the arm-linux-gnueabi-gcc compiler instead of just gcc. I’ll verify it was indeed for an ARM machine with readelf, then scp it from the VM to my host system.
I start by creating the source file with vim. Ubuntu offers many pre-built cross compilers. All you need to do is run a sudo apt update to ensure your package listing is up to date and a sudo apt install -y build-essential gcc-arm-linux-gnueabi will get you what you need. To build, I’ll use the arm-linux-gnueabi-gcc compiler instead of just gcc.
There it is! I’ve successfully cross compiled a simple program to run on an ARM machine. If you have any questions about this please let me know in the comments!
Since you say you can use make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm uImage
you should have arm gnueabi toolchain available at your disposal. It should be then as easy as calling it like
arm-linux-gnueabi-gcc -I../inc *.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With