Simple use of embedded Linux crossover tool chain

Source: Internet
Author: User

Cross tool chain

For a simple hello.c program

#include <stdio.h>

void Main ()

{

printf ("Hello World->\n");

}

We use GCC at Linux compile time

GCC hello.c-o Hello (-o rename), but after compiling the copy to arm inside cannot use, we need special compiler to compile, we will write good program hello.c in Linux not using GCC compile, use ARM-GCC to compile

ARM-LINUX-GCC Hello.c-o Hello

Then copy it into arm and run it.

./hello on the line, output Hello world->

In the embedded development host is compiled, linked to the embedded software of the computer, the target machine is the implementation of embedded software hardware platform


Common Cross Tools

ARM-LINUX-GCC (Cross compiler)

ARM-LINUX-LD (cross-linker)

Arm-linux-readelf

Arm-linux-objdump (Disassembler)

Arm-linux-objcopy (file Format Converter)

Simple way to use:

The GCC compiler in Linux finds the header file in/usr/include/dtdio.h

And ARM-LINUX-GCC compiled we can see through help

ARM-LINUX-GCC (cross compiler) The resulting file format is Elf's

ARM-LINUX-GCC using the same method as GCC

ARM-LINUX-GCC-G (Display debug information)-O (rename)

ARM-LINUX-LD (cross-linker)

ARM-LINUX-LD-TLED.LDF (linker script)-O led.elf (the name specified after the link is the best plus. Elf linked file format is elf) LED.O (linked. o file)

Arm-linux-readelf (Crossover Converter)

Arm-linux-readelf-a (that is, all) led.elf (see the size and end of the program used, platform, etc.)

Arm-linux-objdump-d-S Hello (compiled assembly code) when used in conjunction with ARM-LINUX-GCC ARM-LINUX-GCC best plus-a parameter to facilitate the compilation can and C language to correspond, see understand, (when looking at the main function)

Arm-linux-objcopy (file Format Converter) to replace Elf with binary file

Arm-linux-objcopy-o (output format) binary led.elf (source file) led.bin (binary file)

Simple solution for compile-time errors

View the platforms used by the compiled application using tools (GCC,ARM-LINUX-GCC, etc.) we can use the command file+ the compiled program

For example, file Hello

View the size end using commands such as arm-linux-readelf-a (that is, all) led.elf

View library files that your application must use arm-linux-readelf-d Hello





This article is from the "Cocoa Linux" blog, please be sure to keep this source http://kekelinux.blog.51cto.com/9651825/1603995

Simple use of embedded Linux crossover tool chain

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.