Linux 如何为微处理器 SA1100 安装交叉编译器(在 ubuntu 12.04 LTS 上)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14921463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:02:48  来源:igfitidea点击:

How to install cross compiler (on ubuntu 12.04 LTS) for microprocessor SA1100?

linuxgccubuntucompiler-constructionarm

提问by n00b1990

Can someone please tell me how to install the cross compiler (programming language C) for the SA1100 microprocessor? I have ubuntu 12.04 LTS. I′m a complete noob to Linux, I just installed Ubuntu yesterday. I need a special variant of the GCC compiler that is named "arm-unknown-linux-gnu-gcc" but don know how to do it.

有人能告诉我如何为 SA1100 微处理器安装交叉编译器(编程语言 C)吗?我有 ubuntu 12.04 LTS。我是 Linux 的完全菜鸟,我昨天刚安装了 Ubuntu。我需要一个名为“arm-unknown-linux-gnu-gcc”的 GCC 编译器的特殊变体,但不知道该怎么做。

Can someone please help me?

有人可以帮帮我吗?

采纳答案by Basile Starynkevitch

As I told in comments, try

正如我在评论中所说,尝试

apt-get install gcc-arm-linux-gnueabi 

or

或者

apt-get install gcc-4.7-arm-linux-gnueabi

I also strongly recommend being able to compile an ordinary C program for your Linux system (i.e. learn the basics of gcc, make... commands and how to use some editor like emacsor gedit...) and the cross compiler you want also depends upon the system running on your SA1100 hardware board. Don't forget to pass -Wallto any GCC compilation. You probably want to be able to debug your program (pass -gto GCC at compilation, and use the gdbdebugger). When your program is running well, compile it with -O2to ask GCC to optimize its machine code.

我还强烈建议能够为您的 Linux 系统编译一个普通的 C 程序(即学习gcc, make... 命令的基础知识以及如何使用诸如emacsgedit... 之类的编辑器)并且您想要的交叉编译器也取决于系统在 SA1100 硬件板上运行。不要忘记传递-Wall给任何 GCC 编译。您可能希望能够调试您的程序(-g在编译时传递给 GCC,并使用gdb调试器)。当你的程序运行良好时,编译它-O2以要求 GCC 优化它的机器代码。

Learn to use GNU make-e.g. to write Makefile-s- by reading its documentationand use the arm-linux-gnueabi-gccas the cross-compiler program. (You might want to use remaketo debug your Makefile-s when makedoes not help enough)

通过阅读其文档并使用 GNU作为交叉编译器程序,学习使用 GNU make-eg 编写Makefile-s- 。(您可能想在没有足够帮助时用于调试您的-s )arm-linux-gnueabi-gccremakeMakefilemake

You can get the list of files installed with a package with e.g. dpkg -L gcc-arm-linux-gnueabi

你可以得到一个包安装的文件列表,例如 dpkg -L gcc-arm-linux-gnueabi

A cross compiled program executable for ARM very probably needs a Linux kernel with some libc(or link it statically) at least on the ARM motherboard, and you need some way to transmit the binary program from the Linux desktop to the ARM hardware.

ARM 的交叉编译程序可执行文件很可能需要libc至少在 ARM 主板上具有一些(或静态链接)的 Linux 内核,并且您需要某种方式将二进制程序从 Linux 桌面传输到 ARM 硬件。

回答by Nooty

Add the ppa: https://launchpad.net/gcc-arm-embeddedThe source codes for both are same. Currently supports Ubuntu 10.04/12.04/13.04/13.10/14.04 32 and 64 bit.

添加ppa:https://launchpad.net/gcc-arm-embedded 两者的源代码相同。目前支持 Ubuntu 10.04/12.04/13.04/13.10/14.04 32 位和 64 位。

Detailed explanations to Launchpad PPA can be found at https://help.launchpad.net/Packaging/. That website explains how a PPA is set up and how to add existing PPA and install software from it.

可以在https://help.launchpad.net/Packaging/找到 Launchpad PPA 的详细说明。该网站解释了如何设置 PPA 以及如何添加现有 PPA 并从中安装软件。

Here are quick steps to install toolchain from this PPA on Ubuntu before 14.04. Open a terminal and type :

以下是在 14.04 之前的 Ubuntu 上从此 PPA 安装工具链的快速步骤。打开终端并输入:

  1. sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
  2. sudo apt-get update
  3. sudo apt-get install gcc-arm-none-eabi
  1. sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
  2. sudo apt-get update
  3. sudo apt-get install gcc-arm-none-eabi

To remove installed toolchain, just do :

要删除已安装的工具链,只需执行以下操作:

sudo apt-get remove gcc-arm-none-eabi

sudo apt-get remove gcc-arm-none-eabi

To update the toolchain, just repeat step 2 and 3.

要更新工具链,只需重复步骤 2 和 3。