什么是交叉编译器和跨平台?

发布于 2024-07-24 15:06:13 字数 351 浏览 2 评论 0原文

我对跨平台和交叉编译器的术语有点困惑。 首先让我澄清一下跨平台。 当人们谈论跨平台时,意味着CPU的架构,即X86和X64? 或操作系统,即 Windows 32 位或 Windows 64(服务器或桌面)? UNIX 没有 64 位或 32 位等不同风格。 为什么这样?

.NET和java是交叉编译语言,什么意思? 当程序在.NET中编译时,我们必须选择X86、X64或Any CPU等选项。 那意味着什么? 另外,在安装项目中,我们必须在 x86 和 x64 之间选择选项。 那么,如果程序是在 x86 中编译的,并且在 x64 上创建了 msi 文件,那么它是否可以在 X64 和 x86 上运行,或者在其中任何一个上运行?

I am bit confused with the terms of cross platform and cross compiler. Let me be first clear about the cross platform. When people talk about cross platform it means the architecture of the CPU, i.e, X86 and X64 ? or the OS i.e windows 32 bit or Windows 64 (server or desktop)? UNIX doesn't have different flavours like 64 bit or 32 bit. Why so?

.NET and java is cross compiler language, what it means? When the program is compiled in .NET, we have to choose the option like X86, X64 or Any CPU. What that means? Also in setup project we have to choose the option between x86 and x64. So if the program is compiled in x86 and msi file has been created on x64 will it run on both X64 and x86 or any one of ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

宫墨修音 2024-07-31 15:06:13

当人们谈论跨平台时,指的是CPU的架构,即X86和X64? 或操作系统

两者。 它通常是指在虚拟机中运行的软件或为每个平台单独编译的软件。

UNIX 没有 64 位或 32 位等不同风格。

确实如此。

那么,如果程序是在 x86 中编译的,并且在 x64 上创建了 msi 文件,那么它是否可以在 X64 和 x86 上运行,或者在其中任何一个上运行?

如果您的目标是 x86,amd64 也将运行代码(在 32 位模式下)。 在哪里创建安装程序 msi 文件并不重要。

交叉编译意味着宿主机和目标平台不一样。 例如,在 Linux 计算机上构建 Windows 软件。

When people talk about cross platform it means the architecture of the CPU, i.e, X86 and X64 ? or the OS

Both. It usually means sotfware that runs in a virtual machine or software that is compiled for each platform separately.

UNIX doesn't have different flavours like 64 bit or 32 bit.

It does.

So if the program is compiled in x86 and msi file has been created on x64 will it run on both X64 and x86 or any one of ?

If you target x86, amd64 will also run the code (in 32 bit mode). It shouldn't matter where you create the installer msi file.

Cross compiling means that the host and target platform are not the same. For example building windows software on a Linux computer.

吻泪 2024-07-31 15:06:13

跨平台指的是程序运行的能力在多个不同的平台上。 跨平台代码经常使用各种工具包/语言来实现此目的(Qt、Flash 等)

跨平台-compiler 是一个编译器,它为与编译器本身运行的平台不同的平台生成代码。 嵌入式目标的编译器几乎总是交叉编译器,因为很少有嵌入式目标能够托管编译器本身。

交叉编译器需要一个不假设主机和目标系统兼容的构建系统,即您无法在构建时运行目标可执行文件,例如计算生成代码的运行时方面(例如字大小)。

(交叉编译也可以应用于编译器本身。这被称为加拿大交叉编译,这是一种在不同于编译器运行的主机上构建(交叉)编译器的技术。在这种情况下,我们有三个平台:

  • 编译器构建的平台(build)
  • 。托管编译器(主机)。

怀疑大多数程序员永远不会遇到这种情况。)

Cross-platform refers to the ability of a program to run on multiple different platforms. Cross-platform code frequently uses various toolkits/languages to achieve this (Qt, Flash, etc.)

Cross-compiler is a compiler which generates code for a platform different than the platform on which the compiler itself runs. Compilers for embedded targets are almost always cross-compilers, since few embedded targets are capable of hosting the compiler itself.

Cross-compilers requires a build system which does not assume that the host and target system are compatible, i.e. you cannot run a target executable at build time, for example to figure out runtime aspects of the generated code (such as word size).

(Cross-compilation can also be applied to the compiler itself. This is referred to as Canadian Cross compilation, which is a technique for building a (cross-)compiler on host different from the one the compiler should be run on. In this case we have three platforms:

  • The platform the compiler is built on (build).
  • The platform which hosts the compiler (host).
  • The platform for which the compiler generates code (target).

I suspect that most programmers will never encounter this.)

阳光的暖冬 2024-07-31 15:06:13

我想,跨平台可能表明它运行在 Windows/Mac/*nix 上,或者运行在 x86/x86_64/ARM/PPC 上,但除非另有说明,我相信这通常意味着它运行在不同的操作系统上系统。 例如,“Java 应用程序是跨平台的”,这通常适用于 Java 应用程序可以在 Win/Mac/*nix 上运行的事实。

Cross platform, I suppose, could indicate that it runs on either Windows/Mac/*nix or that it runs on either x86/x86_64/ARM/PPC, but unless otherwise stated I believe that it generally means that it runs on the different operating systems. For example "Java apps are cross-platform" this usually applies to the fact that Java apps can run on Win/Mac/*nix.

已下线请稍等 2024-07-31 15:06:13

“跨平台”是指在许多不同平台上工作的东西,因此可能是操作系统或CPU(类型(x86/MIPS)或位大小(32/64))。 这并不意味着是否需要重建才能在其他平台上运行,这是可以的,例如 QT 可以针对许多平台,但您的应用程序可能需要在每个平台上重建,或者您可能能够构建一次,例如 java 或 .Net

'交叉编译器是指在这个平台上编译出来的程序可以在另一个平台上运行。 从而在 Win32 上构建 WinCE 可执行文件。 或者,您可以通过构建在 Windows 中运行的 GCC 版本,在 Windows 上构建 Linux 应用程序,但输出目标是 Linux/Elf。 如果您有嵌入式设备,您几乎总是进行交叉编译来构建目标可执行文件。

X86、X64 或任何 CPU。 那意味着什么?
它控制 .Net 应用程序如何针对一种架构或不针对一种架构,如果您针对则它不会在两种架构上运行,但编译器许多会进行一些优化。 如果它是非目标(任何 CPU),它将在两者上运行。 如果您直接调用外部 .dll 并硬链接 64 位或 32 位版本,并且因此只希望您的应用程序在同一环境中运行,这主要有用。

在安装程序方面,Windows 64 位可以运行 32 位应用程序和 32 位安装程序,而 64 位应用程序无法在 32 位系统上运行。 在其他平台上,您通常会为您运行的架构(Linux)重建代码,或者在 Mac 上您下载通用可执行文件(我认为内部有多个目标构建)

'cross platform' refers to things working on many different platforms, so that may be OS, or CPU (type (x86/MIPS) or bit size (32/64)). This does not imply if a rebuilt is required to run on the other platforms just that is can, eg QT can target many platforms but you application may need rebuilding on each, or you may be able to build once, like java or .Net

'cross compiler' means a compiler on this platform that makes a program that can run on another platform. Thus build WinCE executables on Win32. Or you may build an Linux application on a window box, by building a version of GCC that runs in windows, but thats output target is Linux/Elf. If you have an embedded device you nearly always cross-compile to build the target executable.

X86, X64 or Any CPU. What that means?
It controls how the .Net app is targeted to one architecture or not, if you target then it won't run on both, but the compiler many make some optimizations. If it's non-targets (Any CPU) it will run on both. This is mainly useful if you directly call into external .dll's and you hard link the 64bit or 32bit version, and therefore only want your application to run in the same environment.

On the installers front Windows 64bit can run 32bit applications and 32bit installers, where-as 64bit applications cannot run on 32bit systems. On other platforms you normally rebuild the code for the architecture your running (Linux) or on the Mac you download universal executables (which I think have multiple targeted builds inside)

老娘不死你永远是小三 2024-07-31 15:06:13

本机编译器:本机编译器是从源代码生成可执行文件的编译器,这些文件又将在具有可用编译器的同一系统上执行。

交叉编译器:交叉编译器是从源代码生成可执行文件的编译器,这些文件又将在可用编译器的不同系统上执行。

BoundsCheck

Native Compilers: Native compilers are those which generates the executable files from the source code which in turn will execute on the same system on which compiler is available.

Cross Compiler: Cross compilers are those which generate the executable files from the source code which in turn will execute on some different system then on which compiler is available.

Find examples on native and cross compilers on BoundsCheck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文