what is cross compiler and cross platform?

会有一股神秘感。 提交于 2021-02-07 03:17:47

问题


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 ?


回答1:


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.




回答2:


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.)




回答3:


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.




回答4:


'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)




回答5:


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



来源:https://stackoverflow.com/questions/1031194/what-is-cross-compiler-and-cross-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!