$ sudo apt-get install gcc-arm-linux-gnueabi
Untuk Ubuntu 10.04 jalankan ini:
sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabi
Test toolchain:
$ arm-linux-gnueabi-gcc -v
Sekarang buat aplikasi sederhana hello-world.c
#include
int main()
{
printf("Hello world for ARM\n");
return 0;
}
Sekarang buat Makefile:
CC=$(CROSS_COMPILE)gcc
all: hello-world.c
$(CC) -o hello-world hello-world.c
clean: rm hello-world
Note: Tab di Makefile harus benar-benar karakter tab bukan spaces. Kalau ada compile error Missing separator ... berarti Makefile menggunakan spaces.
Sekarang compile program diatas:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
jalankan hello-world
$ chmod u+x hello-world
$ ./hello-world
Hasil:
/lib/ld-linux.so.3: No such file or directory
Ini karena hasil binary hanya jalan untuk ARM architecture.
Copy hello-world ke folder rootfs di SD Card
$ sudo cp hello-world /media/rootfs/home/ubuntu
Sekarang booting lagi ARM di development board.
$ /home/ubuntu/hello-world
Hasil:
Hello world for ARM
No comments:
Post a Comment