Meaning of the build, host, and target options in cross-compilation

Source: Internet
Author: User

Reprint http://milodream.diandian.com/post/2012-09-25/40038912065



Meaning of the build, host, and target options in cross-compilation


--build= the platform used to compile the software (your computer's platform now)


--host= the platform on which the software will run (which platform the compiled libraries can run on)


--target= the target platform that the software deals with












Some of the more common parameters in cross-compilation are build, host, and Target, and it is important to understand the meaning of these three things correctly for cross-compilation, which is explained below.


--build= the platform used to compile the software


--host= the platform that the software will run


--target= the target platform that the software deals with




Intuitive understanding, build is the machine you are using, host is the platform that your compiled program can run, and target is the platform that your compiled program can handle.This build and host better understand, but the target is not easy to do, what is the meaning of it? Generally speaking, we usually say that the compilation of the job does not use the target, such as. /configure--build=i386-linux,--Host=arm-linux can be compiled on a 386 platform and can be run onArm Board Program. However, in general, we compile the program, not the compiler tool, if we compile the tool, such as GCC, this target is useful. If we need to compile a gcc for the arm Development Board on one of our machines that can handle the MIPS program, thenTarget is MIPS .The


Uild--building the package host in the build system--after the build is built, the suite can run target in host--the executable file generated by the suite can run on target.


For example, cross-compiling a package on the Gnu/linux system that can run on an AIX machine.


Then build = I*86-pc-linux-gnu host = rs6000-ibm-aix3.2 target = rs6000-ibm-aix3.2


Build a cross-compilation tool on the Gnu/linux system,


This cross-compilation tool can be run on AIX, so that cross-compiled files can be run on arm,


Then: build = I*86-pc-linux-gnu host = rs6000-ibm-aix3.2 target = Arm-linux This can be seen


, when a package is created, it does not have to be built on a local machine, and a different configuration name can be set to generate a different system package.




We use GCC as an example to explain the role of these three.


In GCC compilation we use the


    ./configure--build= Compiler platform--host= run platform--target= Target platform [various compilation parameters]


To configure GCC's source code to compile the GCC compiler we need.




So in this set of configuration parameters:


--build:


What is the name of the platform we are currently running, and if we are currently compiling the system in Intel's Pentium machine, then our--build may be i686-pc-linux-gnu, Of course if we compile on other kinds of machines then this build should be the platform name for that machine.


This parameter will automatically guess the name of the current platform without specifying the general knowledge.




     --host:


That we put this compiled gcc on what platform to run, in the cross-compiling process this needs us to specify, because the machine itself is not aware of how we think, then we can clearly tell it,The program we're going to do is run on "godson",However, there is no direct designation of "godson", so we specify this asMips64el-unknown-linux-gnu(If you save things then use this name, if you want to use a personality name, then you want to understand the meaning of it again, and do a good job in the back of the process requires a few more formalities of the psychological preparation of trouble).


--host can also be unspecified, then host will automatically use build to define itself, but that will no longer be cross-compiling.


Note:--build and--host are identified as cross-compiled by the configuration file at different times.




--target:


The purpose of this parameter is to let the configuration program know that the software is compiled to makeused to process the files on the platform.


Target This parameter is useful only in a few packages, although this parameter is often seen in the./configure--help, but in fact most packages do not require this parameter.


From the meaning of this parameter, it is stated that the target of its processing is only useful when it behaves differently under different platforms, and these files are usually directly or indirectly related to the target platform's instruction system: executable files, for example, can be completely different from executable files used under different platforms, so you must use Corresponding to the program can handle the code can be processed correctly, and if the use of errors may lead to a program error or corrupt files, in order to deal with different platforms under the different coding software, we should specify the target platform to avoid another error processing, and for text files, The same content expression is the same for different platforms, so we don't need to do it specifically for the platform, so we don't have to specify the platform that needs to be processed.




Let's sum it up:


Build: The automatic test in the platform name, if not detected, you need to specify.


Host: Automatically uses the result of build if none is specified.


The build and host are the same when they are compiled locally, which means cross-compilation, if not the same.


Target: Indicates the name of the platform to be processed, if none is specified using the same name as the host, GCC, binutilsis equal to the platform directive related software has this parameter,Most software This parameter is not useful.

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.