Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to crosscompile a hello world C program for ARM [duplicate]

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
like image 610
Embed101 Avatar asked Jan 14 '14 08:01

Embed101


People also ask

Is there a ‘hello world’ for 32-bit ARM?

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:

What compiler should I use to build on an arm machine?

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.

How do I build a cross compiler in Ubuntu?

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.

Is it possible to run a simple program on an arm?

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!


1 Answers

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
like image 142
auselen Avatar answered Sep 30 '22 15:09

auselen