使用交叉编译器时如何确定配置的主机值 [英] How to determine host value for configure when using cross compiler
问题描述
一般问题:如果我使用交叉编译器,我如何知道在运行 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
交叉构建,即BUILD==HOST!=TARGET
用于构建在您的工作站上运行但为目标生成二进制文件的工具链.例如BUILD==HOST==x86 TARGET==arm
跨原生构建,即BUILD!=HOST==TARGET
用于在您的目标上工作并为目标生成二进制文件的工具链.例如 BUILD==x86 HOST==TARGET==ARM
加拿大工具链,即BUILD!=HOST!=TARGET
用于构建架构 A 工具链在 B 上运行并为架构 C 生成二进制文件.例如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]
你会在上面找到所以根据你想要做什么,你需要将它设置为交叉编译.如果所有选项都可用,那么您想在 arm 目标上执行然后设置 --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屋!