可以gcc交叉编译不同的CPU吗? [英] can gcc cross compile for different CPU?

查看:399
本文介绍了可以gcc交叉编译不同的CPU吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装在fedora 16上的gcc是否可以交叉编译不同的CPU,例如SPARC?
我建立了一定的理解,需要一些专家纠正我,如果我错了。不同的操作系统因为访问内核所使用的系统调用或者它们所使用的内核而完全不同。它是否正确?不同的内核理解不同的系统调用访问底层硬件。二进制文件或可执行文件或程序只不过是一堆系统调用。因此每个操作系统都有自己的可执行文件。一个可执行文件意味着运行到窗口伤口不运行在linux上。通过交叉编译任何windown的可执行文件的源代码,我们可以为其他操作系统生成可执行文件。 word PLATFORM表示操作系统。 POSIX是用于类UNIX操作系统的特定设计标准。
我们通常为不同的操作系统交叉编译。但是我们可以交叉编译不同的硬件呢?例如,在没有OS

Is it possible for gcc, installed on fedora 16, to cross compile for a different CPU, say SPARC? I have build a certain understanding, need some expert to correct me if I am wrong. Different operating systems differ by the system calls they use to access the kernel or entirely by the kernel they use. IS THIS CORRECT? different kernels understands different systems calls for accessing underlying hardware. binaries or executables or programs are nothing but a bunch of system calls only. therefore every OS has its own executable. an executable meant to run to on windows wound not run on linux. by cross compiling the source code of any windown's executable we can generate executable for other OSs. word PLATFORM means operating system. POSIX are certain design standards for UNIX-like OSs. we usually cross compile for different OSs. BUT can we cross compile for different hardware too? for example, in case of a microcontroller which does not have an OS?

推荐答案

否的微控制器的情况下。您不能使用本机(x86)gcc编译不同架构的程序文件。为此,您需要一个特定于该处理器体系结构的交叉编译器gcc。

No. You can't use native machine (x86) gcc for compiling program files for a different architecture. For that you require a cross-compiler-gcc that is specific to that processor architecture.

您对系统调用OS的了解是正确的。每个操作系统都有自己的一套被库使用的系统调用。这些库最终将被转换为处理器的机器语言。

Your understanding about system calls for OS is correct. Each OS has its own set of system call which is been used by library. These libraries at the end will be translated into machine language for the processor.

每个处理器架构都有自己的指令集,即指令集架构(ISA)。因此,当用高级语言编写的程序(如C)被编译时,它应该从它的ISA转换成机器语言。此作业由编译器(gcc)完成。编译器将仅特定于一个处理器架构。例如gcc是用于x86处理器。所以如果你想要一个编译器为不同的处理器在你的x86机器,你应该去交叉编译器的处理器。

Each Processor Architecture has its own set of instruction know as Instruction Set Architecture(ISA). So when a program written in high-level-language (like C) is compiled, it should be converted into machine language from its ISA. This job is done by the compiler(gcc). A compiler will be specific to only one processor architecture. For example gcc is for x86 processor. So if you want a compiler for different processor in you x86 machine you should go for a cross-compiler of that processor.

这篇关于可以gcc交叉编译不同的CPU吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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