Hardware Reference
In-Depth Information
Setting Up Variables
Now, set up a couple of variables to know which compiler you are using:
host$ export ARCH=arm
host$ export CROSS_COMPILE=arm-linux-gnueabihf-
These lines set up the standard environmental variables so that you can determine which
cross-development tools to use. Test the cross compiler by adding Example 7-3 to a file
named helloWorld.c .
Example 7-3. Simple helloWorld.c to test cross compiling (helloWorld.c)
#include <stdio.h>
int main ( int argc , char ** argv ) {
printf ( "Hello, World! \n " );
}
You can then cross-compile by using the following commands:
host$ ${CROSS_COMPILE}gcc helloWorld.c
host$ file a.out
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.31,
BuildID[sha1]=0x10182364352b9f3cb15d1aa61395aeede11a52ad, not
stripped
The file command shows that a.out was compiled for an ARM processor.
Search WWH ::




Custom Search