Raspberry Pi 2 Raspyberry Pi2 cross compilation app

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.