“./configure"有什么区别?选项“--build",“--host"和“--目标"? [英] What's the difference of "./configure" option "--build", "--host" and "--target"?

查看:41
本文介绍了“./configure"有什么区别?选项“--build",“--host"和“--目标"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

脚本 ./configure 接受 3 个选项 --build--host--target.我混淆了他们的角色.它们的区别和语义是什么?

The script ./configure accepts 3 options --build, --host and --target. I'm confusing their roles. What's the difference and semantics of them?

推荐答案

这篇博文 并在 GCC 配置条款--target 仅在您编译工具链时适用.当您对库或二进制文件进行正常的交叉编译时,您使用

As noted in this blog post and alluded to in the GCC Configure Terms, --target only applies when you are compiling toolchains. When you are doing normal cross-compilation of a library or binary you use

--build=the architecture of the build machine
--host=the architecture that you want the file to run on

但是,当您构建工具链时,事情会变得更加复杂.我认为以下是正确的(虽然我不能说我曾经手动编译过交叉调试器):

However, when you are building toolchains, things can get more complicated. I think that the following is correct (though I can't say I've ever manually compiled a cross-debugger):

假设您有:

  • 您将在其上进行所有编译的 powerpc 构建机器
  • 几个带有 mips 处理器的嵌入式设备,您的代码将在这些设备上运行
  • 您将用于在现场调试这些设备的 x86 笔记本电脑

您将配置和构建调试服务器(例如 gdbserver)以在您的嵌入式设备上运行

You would configure and build your debugging server (eg gdbserver) to run on your embedded device with

./configure --build=powerpc --host=mips

这样你就可以在你的嵌入式设备上安装并运行gdbserver :1234 a.out"来开始调试和监听端口 1234.

so that you could putty on to your embedded device and run "gdbserver :1234 a.out" to start debugging and listen on port 1234.

然后您将使用

./configure --build=powerpc --host=i686 --target=mips 

您可以将其复制到 x86 笔记本电脑,以便在现场运行gdbclient Embedded.device:1234"以调试 a.out 程序.

which you would copy to your x86 laptop so that in the field you could run "gdbclient embedded.device:1234" in order to debug your a.out program.

这一切也适用于编译器,您可能想查看上面的 GCC 链接或有关 加拿大交叉编译.

This all applies to compilers too for which you might want to look at the GCC link above or this section about the Canadian cross compile.

另请注意,在实践中,您可能不会看到指定的构建、主机或目标,因为根据 这个 Autoconf 手册页,目标默认为主机,主机为构建,构建为 config.guess 的结果."

Also note that, in practice, you might not see build, host or target specified because, according to this Autoconf manual page, "target defaults to host, host to build, and build to the result of config.guess."

一句话,在--build上构建代码,在--host上运行,--target架构环境.

In a word, build the code on --build, run it on --host with --target architecture environment.

这篇关于“./configure"有什么区别?选项“--build",“--host"和“--目标"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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