使用交叉编译器时如何确定要配置的主机值 [英] How to determine host value for configure when using cross compiler

查看:235
本文介绍了使用交叉编译器时如何确定要配置的主机值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般问题:如果使用交叉编译器,如何确定运行configure时应提供的"--host"选项的值?

General question: If I use a cross compiler, how can I tell the value of the "--host" option I should give when I run configure?

特定:我正在为arm64 arch使用交叉编译器.正确使用的"--host"值是什么?

Specific: I'm using cross compiler for arm64 arch. What is the correct "--host" value to use?

推荐答案

如果使用交叉编译器,如何确定运行./configure时应提供的--host选项的值?

If I use a cross compiler, how can I tell the value of the --host option I should give when I run ./configure?

在讨论工具链创建时,必须区分三台机器

Three machines must be distinguished when discussing toolchain creation

  • 用于构建工具链的构建机器.
  • 主机,将在其中执行工具链.
  • 目标计算机,其中由 工具链已执行.
  • The build machine, where the toolchain is built.
  • The host machine, where the toolchain will be executed.
  • The target machine, where the binaries created by the toolchain are executed.

工具链可能有四种常见的构建类型:

Four common build types are possible for toolchains are:

  • 本机版本,即BUILD==HOST==TARGET
    用于为工作站构建普通的gcc.例如BUILD==HOST==TARGET==x86

  • Native build i.e. BUILD==HOST==TARGET
    Used to build normal gcc for workstation. e.g. BUILD==HOST==TARGET==x86

交叉构建,即BUILD==HOST!=TARGET
用于构建可在您的工作站上运行但为目标生成二进制文件的工具链.例如BUILD==HOST==x86 TARGET==arm

Cross-build i.e. BUILD==HOST!=TARGET
Used to build toolchain that works on your workstation but generates binary for target. e.g. BUILD==HOST==x86 TARGET==arm

跨本地构建,即BUILD!=HOST==TARGET
用于在目标上运行并为目标生成二进制文件的工具链.例如BUILD==x86 HOST==TARGET==ARM

Cross-native build i.e. BUILD!=HOST==TARGET
Used to toolchain that works on your target and generates binary for target. e.g BUILD==x86 HOST==TARGET==ARM

加拿大工具链,即BUILD!=HOST!=TARGET
用于构建ARCHITECTURE A的工具链在B上运行并为C生成二进制文件,例如BUILD==x86 HOST==mac TARGET==arm

Canadian toolchain i.e. BUILD!=HOST!=TARGET
Used to build ARCHITECTURE A a toolchain runs on B and generates binary for architecture C. e.g.BUILD==x86 HOST==mac TARGET==arm

有了武装,这些基本知识就会浮出水面.

With armed this basics coming to your question.

对于任何软件,请先运行./configure --help

For any software, first run ./configure --help

主机类型:

--build=BUILD           configure for building on BUILD [BUILD=HOST]
--host=HOST             configure for HOST [guessed]
--target=TARGET         configure for TARGET [TARGET=HOST]

您将在上面找到,因此根据您要执行的操作,需要将其设置为交叉编译.如果所有选项都可用,那么您要在手臂目标上执行,然后设置--host={your toolchain triplet} --target={your toolchain triplet}.

You will find above so depending on what you want to do, you need to set it for cross compiling. If all options are available, then you want to execute on arm target then set --host={your toolchain triplet} --target={your toolchain triplet}.

例如,如果使用的是arm-none-linux-gnueabi-gcc,则设置--host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi.这将写入您的makefile. 最后,生成的可执行文件将在目标上运行.对于--build,它将自动设置,无需担心.

For example, if you are using arm-none-linux-gnueabi-gcc, set --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi. This will write to your makefile. Finally, generated executable will run on target. For --build this will be automatically set, no need to worry.

对于某些软件包,只有两个选项可用.这里是否设置host足以交叉编译

For some software package only two option available i.e host and build. here if set host is enough to cross-compile

特定:我正在对arm64 arch使用交叉编译器.正确使用--host值是什么?

Specific: I'm using cross compiler for arm64 arch. What is the correct --host value to use?

对于x86_64,通常给出--host={triplet},因此我认为通过为您的工具链设置--host={triplet},同样适用于arm64,但是我不确定.

For x86_64, --host={triplet} is generally given, so I think the same should work for arm64 by setting --host={triplet} for your toolchain, but I'm not sure.

这篇关于使用交叉编译器时如何确定要配置的主机值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆