Linux innerhalb einer virtuellen Maschine > Programm kompilieren

Navigation:

 

Linux innerhalb einer virtuellen Maschine >



Programm kompilieren

Previous pageReturn to chapter overviewNext page

Testen Sie die Toolchain indem Sie das einfache C-Programm hello_world.c,  im Verzeichnis /home/vadmin/Desktop/, kompilieren.

 

hello-world.c

#include <stdio.h>

main()

{

printf(”Hello World\n”);

}

 

Hierfür doppelklicken Sie das auf dem Desktop befindliche Shell-Skript compile_ARM9.sh. Es befindet sich im selben Verzeichnis wie das C-Programm. Das C-Programm wird erstellt und in das Verzeichnis /nfs/rootfs_ecpuxxx/root kopiert.

 

compile_ARM9.sh

#!/bin/bash

 

#compiling

 

/usr/local/arm-2007q1/bin/arm-none-linux-gnueabi-gcc \

-o hello_world hello_world.c

 

if [ "$?" != "0" ] # check if compiling successfull

 then echo

      echo "error(s) found while compiling"

      exit 100

 else echo

      echo "compiling successfull"

fi

 

#copy binary file to /root's ARM 9  board

cp hello_world /nfs/rootfs_ecpu1100/root/hello_world

cp hello_world /nfs/rootfs_ecpu800/root/hello_world

 

#change mode of binary file

chmod 777 /nfs/rootfs_ecpu1100/root/hello_world

chmod 777 /nfs/rootfs_ecpu800/root/hello_world

 

read -p "press Enter to continue ..." enter

 

Somit können Sie das Programm nach dem Einloggen auf das ARM9 Board direkt aufrufen.

Rufen Sie es auf das ARM9 Board auf (aus dem Verzeichnis /root aus):

./hello-world