Pi uses the BCM2836 of the ARMV7 architecture to download the cross compiler ARM-LINUX-GNUEABIHF-GCC.
Local Environment: UBUNTU14 + x86_64
1. Download the compiler address:
1). Linaro Open Source organization has the relevant cross-tool chain download, click to enter the page to choose to download, address: https://launchpad.net/linaro-toolchain-binaries/+download
2). The above web site speed is slow, always download failed. Find the domestic website Http://pan.baidu.com/s/1pJ2rdkZ
2. After downloading, unzip, and set the Gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin directory to the System environment variable.
gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin$ file arm-linux-gnueabihf-gcc-4.9.1
Arm-linux-gnueabihf-gcc-4.9.1:elf 32-bit lsb executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 2.6.15, stripped
span>
The cross-compiler downloaded here is 32-bit, ensuring that your system supports the operation of 32-bit programs.
3. Prepare the test code MAIN.C:
#include <stdio.h>
int main ()
{
printf ("Hellow world!\n");
}
4. Compiling
ARM-LINUX-GNUEABIHF-GCC main.c-v
Detailed cross-compilation options are: collect_gcc_options= '-V '-march=armv7-a '-mtune=cortex-a9 '-mfloat-abi=hard '-mfpu=vfpv3-d16 '- Mthumb '-mtls-dialect=gnu '
Compilation Result:
File a.out
A.out:elf 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 3.1.1 , buildid[sha1]=3103ff5892a051b7e185e8ae88bf6cb997af7781, not stripped
5. Implementation
Upload to Pi and execute the following results:
[Email protected] ~ $./a.out
Hellow world!
[Email protected] ~ $
Raspberry Pi 2 Raspyberry Pi2 cross compilation app