有没有办法使用GCC到C转换为MIPS的方法吗? [英] Is there a way to use gcc to convert C to MIPS?

查看:730
本文介绍了有没有办法使用GCC到C转换为MIPS的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了C到MIPS转化为一类,我要检查它反对集会。我听说有一种配置GCC,使其可以在c code转换为MIPS架构,而不是x86架构(我的电脑用户的英特尔i5处理器)的方式,并打印输出。

I completed a C to MIPS conversion for a class, and I want to check it against the assembly. I have heard that there is a way of configuring gcc so that it can convert C code to the MIPS architecture rather than the x86 architecture (my computer users an Intel i5 processor) and prints the output.

运行在Ubuntu的终端(自带GCC),什么命令我用它来配置GCC转换为MIPS?有什么我需要安装呢?

Running the terminal in Ubuntu (which comes with gcc), what command do I use to configure gcc to convert to MIPS? Is there anything I need to install as well?

编辑:
让我澄清一下。请阅读本。
我不希望使用它的编译器,或者有人说好了,你可以交叉编译,而是你应该使用具有对如何建立没有说明这个东西好了。

Let me clarify. Please read this. I'm not looking for which compiler to use, or people saying "well you could cross-compile, but instead you should use this other thing that has no instructions on how to set up."

如果你要张贴,至少参考我的指令。 GCC来与Ubuntu。我没有关于如何安装编译器的经验,这是不容易找到在线教程比GCC其他任何东西。再有就是交叉编译的我需要了解以及案件。谢谢你。

If you're going to post that, at least refer me to instructions. GCC came with Ubuntu. I don't have experience on how to install compilers and it's not easy finding online tutorials for anything other than GCC. Then there's the case of cross-compiling I need to know about as well. Thank you.

推荐答案

GCC的可以的生产组装code进行了大量的架构,包括MIPS。但是,建筑给定GCC例如当目标本身GCC编译决定。在precompiled二进制文件,你会在Ubuntu系统发现知道的x86(可能是32位和64位模式下),但不是MIPS。

GCC can produce assembly code for a large number of architectures, include MIPS. But what architecture a given GCC instance targets is decided when GCC itself is compiled. The precompiled binary you will find in an Ubuntu system knows about x86 (possibly both 32-bit and 64-bit modes) but not MIPS.

GCC编译与目标体系结构从哪个GCC本身将运行被称为$ P $架构不同pparing一个的交叉编译工具链的。这是可行的,但需要相当多的文档阅读和耐心;你通常需要先建立一个交叉汇编和交叉连接器(GNU binutils的),然后建立跨海湾合作委员会本身。

Compiling GCC with a target architecture distinct from the architecture on which GCC itself will be running is known as preparing a cross-compilation toolchain. This is doable but requires quite a bit of documentation-reading and patience; you usually need to first build a cross-assembler and cross-linker (GNU binutils), then build the cross-GCC itself.

我建议使用 buildroot的。这是一套旨在帮助生产一个完整的交叉编译工具链和实用程序的脚本和makefile文件。在一天结束时,你会得到一个完整的操作系统和开发工具的目标系统。这包括交叉编译你了。

I recommend using buildroot. This is a set of scripts and makefiles designed to help with the production of a complete cross-compilation toolchain and utilities. At the end of the day, you will get a complete OS and development tools for a target system. This includes the cross-compiler you are after.

另一种完全不同的解决方案是使用 QEMU 。这是各种处理器和系统,包括MIPS系统的仿真器。你可以用它来与MIPS处理器上运行一个虚拟机,并​​且,这台机器内安装一个操作系统MIPS,例如 Debian的,一个Linux发行版。这样,你得到的原始的海湾合作​​委员会(一个MIPS系统上运行和生产code为MIPS海合会)。

Another quite different solution is to use QEMU. This is an emulator for various processors and systems, including MIPS systems. You can use it to run a virtual machine with a MIPS processor, and, within that machine, install an operating system for MIPS, e.g. Debian, a Linux distribution. This way, you get a native GCC (a GCC running on a MIPS system and producing code for MIPS).

QEMU的方法可能是一点点简单的;采用交叉编译需要有些发毛细节一定的了解。无论哪种方式,你需要的可用磁盘空间大约1 GB。

The QEMU way might be a tad simpler; using cross-compilation requires some understanding of some hairy details. Either way, you will need about 1 GB of free disk space.

这篇关于有没有办法使用GCC到C转换为MIPS的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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