Cross-compilation refers to cross-compiler compilation on a host platform (such as a PC) that can be performed on other platforms (such as arm) the process of running the code. A local compiler means that the compiled program can run on a local machine (that is, the machine that runs the compiler), but the program compiled by the cross compiler cannot run on the local machine.
The emergence and prevalence of the concept of cross-compilation is synchronized with the extensive development of embedded systems. Our commonly used computers
The software must compile the code written in advanced computer languages (for example
C code) Compile (compile) binary code that can be recognized and executed by computers. For example, on Windows, we can use visual c ++
Development Environment, write programs and compile them into executable programs. In this way, we use the Windows tool on the PC platform for Windows
This compilation process is called native.
Compilation, which can be understood as local compilation in Chinese. However, when developing embedded systems, the target platform for running programs usually has limited storage space and computing capabilities, such as common
On the ARM platform, the general static storage space is about 16 to 32 MB, and the CPU clock speed is about between 100 MHz and 500 MHz. In this case
It is impossible to compile the local machine on the ARM platform, because the general compilation tool chain (compilation tool)
Chain) requires a lot of storage space and a strong CPU computing capability. To solve this problem, the cross-compilation tool came into being. With the cross-compilation tool, we can
A host platform (such as a PC) with strong CPU capabilities and sufficient storage controls can compile executable programs for other platforms.
To perform cross-compilation, We need to install the corresponding cross-compilation tool chain on the host platform, and then use this cross-compilation tool chain to compile our source code, finally, code that can be run on the target platform is generated. Common examples of cross-compilation are as follows:
- On a Windows PC, using ADS (ARM development environment) and the ARMCC compiler, You can compile executable code for the arm cpu.
- On a Linux PC, the executable code for the Linux ARM platform can be compiled using the arm-Linux-GCC compiler.
- On a Windows PC, run the arm-elf-GCC compiler in the cygwin environment to generate executable code for the arm cpu.
In addition, most of the Cross-compilation processes of Embedded Linux operating systems are completed on the Linux PC platform. At this time, programmers will install the cross-compilation tool chain on a PC running the Linux operating system, and use the development tools provided by GNU to conveniently develop and debug embedded application software.