原文地址:http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/

A cross compiler is a compiler that runs on one platform/architecture but generates binaries for another platform/architecture. With devices like the Raspberry Pi, where you really don’t have much CPU or memory to work with, if you’re doing any heavy compiling (like when working on the kernel) a cross compiler is the only way to go. For example, I build all my Raspberry Pi kernels on my nice Sandy Bridge Xeon E3 home server where they compile in only a fraction of the time they would on the Pi.

While there are a lot of different methods for building cross-compilers, by far the quickest and easiest is to use crosstool-ng. This is a set of scripts that bring up a menuconfig-like interface to choose your compiler settings, then goes off and downloads what it needs, patches it, configures it, builds it and installs it all for you. Here’s how to get started:

  1. Download crosstool-ng from the project web site. I’ve used version 1.15.2 as that was the latest when I wrote this.
  2. Unpack the tarball and cd into the unpacked directory, then run ./configure --prefix=/opt/cross. You can pick somewhere else instead of /opt/cross but that’s where I like to keep it.
  3. Run make and sudo make install.
  4. Make sure /opt/cross/bin is in your $PATH.

Right, so that’s crosstool-ng installed and ready to build a toolchain for you. Next, to actually create your Raspberry Pi toolchain:

  1. Create a directory somewhere in your home directory that crosstool-ng will use as a staging ground. This will contain your toolchain configuration, downloaded files, and intermediary build results. This is not where your final toolchain will end up, and does take up quite a lot of space (3.5GB and up for me). cd into your chosen directory.
  2. Run ct-ng menuconfig. You should see the ct-ng configuration menu.
  3. Go into Paths and misc options. Enable Try features marked as EXPERIMENTAL. This is important.
  4. While you’re there you may want to change your Prefix directory. I like to put all my toolchains in /opt/cross/x-tools/${CT_TARGET} instead of ${HOME}/x-tools/${CT_TARGET}.
  5. Go back to the main menu and select Target options.
  6. Change the Target architecture to arm. Leave Endianness set to Little endian and Bitness set to 32-bit.
  7. Go back to the main menu and select Operating system (skip Toolchain options, the defaults are fine).
  8. Change Target OS to linux.
  9. Go back to the main menu and select Binary utilities.
  10. Change binutils version to 2.21.1a or whichever is the latest that isn’t marked as experimental. Probably unnecessary but I prefer this.
  11. Go back to the main menu and select C compiler.
  12. Enable the Show Linaro versions (EXPERIMENTAL) option.
  13. In the gcc version field, choose the linaro-4.6-2012.04 (EXPERIMENTAL) compiler. You’re free to choose a different one but I know this one works well. I do recommend the Linaro versions over the vanilla ones for the RPi.
  14. All the other settings are fine left at their default values. Exit the configuration tool and save your changes.
  15. Run ct-ng build.
  16. Go away and make a coffee, etc… This bit will take some time.
  17. You should end up with a freshly baked arm compiler ready for building kernels (and other things) for your Raspberry Pi in your Prefix directory you chose above.
  18. Just add your compiler directory to your $PATH and start compiling. If you used my preferred prefix directory, you would want to add /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin.

利用crosstool-ng自动化编译交叉编译环境(转)的更多相关文章

  1. 构建Jenkins自动化编译管理环境

    今天研究了一下Jenkins,有了一个粗浅的认识,顺手把构建的过程说一下,后续慢慢补充: (1)Secure CRT 连接到Linux服务器 要注意的一点是,要搞好一个文件传输的路子,否则不好传东西. ...

  2. 在CentOS上构建.net自动化编译环境

             我们知道在Windows上我们很容易构建于MSBuild的自动化编译环境,那么在CentOS也是可以的,主要是需要Mono. 在这儿我们选择Jenkins+Gitlab+Mono在C ...

  3. Web自动化框架之五一套完整demo的点点滴滴(excel功能案例参数化+业务功能分层设计+mysql数据存储封装+截图+日志+测试报告+对接缺陷管理系统+自动编译部署环境+自动验证false、error案例)

    标题很大,想说的很多,不知道从那开始~~直接步入正题吧 个人也是由于公司的人员的现状和项目的特殊情况,今年年中后开始折腾web自动化这块:整这个原因很简单,就是想能让自己偷点懒.也让减轻一点同事的苦力 ...

  4. 建立树莓派raspberry交叉编译环境以及编译内核

    最近买了一个树莓派,玩了几天,虽然已经有很多人玩了,现在玩好像有点晚了,但是他确实是个好东西,学好它,对嵌入式的整个开发流程也就会熟悉很多.虽然性能不是很强和现在的BB-BLACK比有点慢了,但是它便 ...

  5. 交叉编译环境以及开发板上-/bin/sh: ./hello: not found(使用arm-linux-gcc -static -o 来进行静态编译)

    目标板是S3C2440.至于交叉编译环境的搭建就不多说了,网上很多教程. 搭建好了交叉编译环境后,第一件事就是传说中的”Hello,World!”. 一. 主机编译环节 我使用的系统是ubuntu10 ...

  6. 从头编译ARM交叉编译环境

    首先Cygwin需安装基本的命令 例如make binutils gcc 还有diffutils 没有他会报找不到cmp命令 这些都可以在setup.exe中找到 编译gcc时,需要注意一个原则:不要 ...

  7. Linux 14.04lts 环境下搭建交叉编译环境arm-linux-gcc-4.5.1

    交叉编译工具链是为了编译.链接.处理和调试跨平台体系结构的程序代码,在该环境下编译出嵌入式Linux系统所需要的操作系统.应用程序等,然后再上传到目标板上. 首 先要明确gcc 和arm-linux- ...

  8. Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程)

    Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程) 声明:本教程在参考了以下博文,并经过自己的摸索后实际操作得出,本教程系本人原创,由于升级 ...

  9. Ubuntu 树莓派2b交叉编译环境

    在一个平台上生成另一个平台上的可执行代码.为什么要大费周折的进行交叉编译呢?一句话:不得已而为之.有时是因为目的平台上不允许或不能够安装所需要的编译器,而又需要这个编译器的某些特征:有时是因为目的平台 ...

随机推荐

  1. java代码---------常用的方法indexOf()和substring()方法的小结、主要是下标都是从0开始,很重要,错了就那个差远了啊

    package com.s.x; //indexOf()方法从字符起始处的第一个位子开始的位置 //substring public class Wang { public static void m ...

  2. json对象转换

    String modules =...; //json格式的String对象 //String对象转换为JSON格式数组 JSONArray moduleArr=JSONObject.parseArr ...

  3. 记录关于ubuntu无线上网只能ping通5~7个数据包的问题

    问题是这样的,我的笔记本(ubuntu desktop)连接上wifi后,信号很好,但是上网上不了,ping网关也不通,ping外网仅仅只有当笔记本刚刚连接上wifi的时候能ping通5至6个包,然后 ...

  4. oracle 存储过程 建表插值等

    建表.插值的procedure create or replace procedure CREATE_EMP is v_createsql ); v_insertsql ); begin v_crea ...

  5. cnzz 模拟请求登录(传入url get data ) demo

    /** * * @Title: init * @Description: TODO 初始化httpclien * @param url * cnzz对应的链接 * @param password * ...

  6. 遇到版本兼容问题时 Newtonsoft.Json

    <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <depen ...

  7. solr解决访问安全

    Tomcat7,solr3.6,mmseg1.8 1:环境的搭建 1:解压tomcat,solr,mmseg4j 2:复制dist文件夹下apache-solr.war到tomcat的webapp文件 ...

  8. Idea2016远程调试Java项目

    一.在IDEA中配置远程tomcat 1.打开配置页面 选择"+" → "Tomcat Server" → "Remote" 填写名称和目标 ...

  9. RESTful基础知识

    RESTful简介 互联网软件的架构原则,定名为REST,即Representational State Transfer的缩写.翻译是"表现层状态转化". 如果一个架构符合RES ...

  10. Consul 简介、安装、常用命令的使用

    1 Consul简介 Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,Consul的方案更"一站式" ...