利用crosstool-ng自动化编译交叉编译环境(转)
原文地址: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:
- Download crosstool-ng from the project web site. I’ve used version 1.15.2 as that was the latest when I wrote this.
- 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. - Run
make
andsudo make install
. - 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:
- 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. - Run
ct-ng menuconfig
. You should see the ct-ng configuration menu. - Go into Paths and misc options. Enable Try features marked as EXPERIMENTAL. This is important.
- 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}
. - Go back to the main menu and select Target options.
- Change the Target architecture to arm. Leave Endianness set to Little endian and Bitness set to 32-bit.
- Go back to the main menu and select Operating system (skip Toolchain options, the defaults are fine).
- Change Target OS to linux.
- Go back to the main menu and select Binary utilities.
- Change binutils version to 2.21.1a or whichever is the latest that isn’t marked as experimental. Probably unnecessary but I prefer this.
- Go back to the main menu and select C compiler.
- Enable the Show Linaro versions (EXPERIMENTAL) option.
- 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.
- All the other settings are fine left at their default values. Exit the configuration tool and save your changes.
- Run
ct-ng build
. - Go away and make a coffee, etc… This bit will take some time.
- 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.
- 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自动化编译交叉编译环境(转)的更多相关文章
- 构建Jenkins自动化编译管理环境
今天研究了一下Jenkins,有了一个粗浅的认识,顺手把构建的过程说一下,后续慢慢补充: (1)Secure CRT 连接到Linux服务器 要注意的一点是,要搞好一个文件传输的路子,否则不好传东西. ...
- 在CentOS上构建.net自动化编译环境
我们知道在Windows上我们很容易构建于MSBuild的自动化编译环境,那么在CentOS也是可以的,主要是需要Mono. 在这儿我们选择Jenkins+Gitlab+Mono在C ...
- Web自动化框架之五一套完整demo的点点滴滴(excel功能案例参数化+业务功能分层设计+mysql数据存储封装+截图+日志+测试报告+对接缺陷管理系统+自动编译部署环境+自动验证false、error案例)
标题很大,想说的很多,不知道从那开始~~直接步入正题吧 个人也是由于公司的人员的现状和项目的特殊情况,今年年中后开始折腾web自动化这块:整这个原因很简单,就是想能让自己偷点懒.也让减轻一点同事的苦力 ...
- 建立树莓派raspberry交叉编译环境以及编译内核
最近买了一个树莓派,玩了几天,虽然已经有很多人玩了,现在玩好像有点晚了,但是他确实是个好东西,学好它,对嵌入式的整个开发流程也就会熟悉很多.虽然性能不是很强和现在的BB-BLACK比有点慢了,但是它便 ...
- 交叉编译环境以及开发板上-/bin/sh: ./hello: not found(使用arm-linux-gcc -static -o 来进行静态编译)
目标板是S3C2440.至于交叉编译环境的搭建就不多说了,网上很多教程. 搭建好了交叉编译环境后,第一件事就是传说中的”Hello,World!”. 一. 主机编译环节 我使用的系统是ubuntu10 ...
- 从头编译ARM交叉编译环境
首先Cygwin需安装基本的命令 例如make binutils gcc 还有diffutils 没有他会报找不到cmp命令 这些都可以在setup.exe中找到 编译gcc时,需要注意一个原则:不要 ...
- Linux 14.04lts 环境下搭建交叉编译环境arm-linux-gcc-4.5.1
交叉编译工具链是为了编译.链接.处理和调试跨平台体系结构的程序代码,在该环境下编译出嵌入式Linux系统所需要的操作系统.应用程序等,然后再上传到目标板上. 首 先要明确gcc 和arm-linux- ...
- Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程)
Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程) 声明:本教程在参考了以下博文,并经过自己的摸索后实际操作得出,本教程系本人原创,由于升级 ...
- Ubuntu 树莓派2b交叉编译环境
在一个平台上生成另一个平台上的可执行代码.为什么要大费周折的进行交叉编译呢?一句话:不得已而为之.有时是因为目的平台上不允许或不能够安装所需要的编译器,而又需要这个编译器的某些特征:有时是因为目的平台 ...
随机推荐
- centos开机提示CPU无法识别的问题
centos版本和对应cpu兼容性,官方网址: https://access.redhat.com/support/policy/intel Red Hat Enterprise Linux Vers ...
- .NET System.Web.HttpContext.Current.Request报索引超出数组界限。
移动端使用Dio发送 FormData, 请求类型 multipart/form-data, FormData内可以一个或多个包含文件时. 请求接口时获取上传的fomdata数据使用 System.W ...
- Mac Terminal终端光标的快捷键操作
2016年08月18日 18:26:06 阅读数:4217 Mac Terminal终端和linux上终端光标的快捷键操作是一样的,都是来自Emacs这个神级的编辑器,由于我以前vim用的多,没怎么用 ...
- cinder-backup详细介绍
首先介绍Snapshot snapshot可以为volume创建快照,快照中保存了volume当前的状态,此后可以通过snapshot回溯 主要采用了Copy On Write算法.进行快照时,不牵涉 ...
- python开发_python关键字
python3.3.2中的关键字如下: The following identifiers are used as reserved words, or keywords of the languag ...
- CentOS7.6安装Maven
官网下载地址:http://maven.apache.org/download.cgi 第一步:软件下载安装 进行安装目录:cd /opt/software (如果目录不存在,请先创建目录) 下载二进 ...
- python查找文件相同的和包含汉字的
#!/usr/bin/env python # Version = 3.5.2 import os import time d_path = '/data/media' log_file = 'res ...
- Daemon进程
这又是一个有趣的概念,daemon在英语中是"精灵"的意思,就像我们经常在迪斯尼动画里见到的那些,有些会飞,有些不会,经常围着动画片的主人公转来转去,啰里啰唆地提一些忠告,时不时倒 ...
- eclipse中的实用快捷键
之前有写过“myeclipse实用快捷键”,今天总结一下“eclipse中的快捷键”. 1.打开文件Crtl+Shift+R: 2. 打开类文件包括能看到字在哪个jar Ctrl+Shift+T: ...
- 如何将Excel日期快速转化为文本格式?
Excel表中日期格式其实是数值,有时候需要原样转成文本,有时候也要将文本转成日期. 我发现了一个方法,估计是最快的了.不需要用那一堆year() month()之类的函数. 快速将日期格式转化为文本 ...