http://blog.csdn.net/goodwillyang/article/details/39779183
这篇文章主要讲搭建基于ARM(BBB)的交叉编译环境,开发环境 BBB+ubuntu14 照惯例,先贴上参考链接
1. 创建工作目录
sudo mkdir -p /usr/local/arm >/dev/null
sudo chmod 777 /usr/local/arm
cd /usr/local/arm
*mkdir -p 创建多层目录
2.下载toolchain
法一. 对于UbuntuTrusty Tahr (14.04LTS)
Linaro maintains cross compilers that run on Ubuntu.With current releases, the method for adding a foreign architecture isslightly more complicated than for Debian. Please note — thisworks on Ubuntu 14 and later.
sudo apt-get install python-software-properties sudo add-apt-repository universe sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabi sudo apt-get install qemu-system-arm qemu-system-x86法二. 从 linaro官网下载bin文件 点击打开链接
cd /usr/local/arm
wget -c https://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
tar -xvJf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
ln -s gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux /usr/local/arm/toolchain
*ln -s src dest, 删除软连接, rm -rf symbolic_name(目标文件) 注意不是rm -rf symbolic_name/ see ln
3. 安装c-compile cache ccache
cd /usr/local/arm/toolchain mkdir bin-ccache cd bin-ccache sudo apt-get install ccache ln -s $(which ccache) arm-linux-gnueabihf-gcc ln -s $(which ccache) arm-linux-gnueabihf-g++ ln -s $(which ccache) arm-linux-gnueabihf-cpp ln -s $(which ccache) arm-linux-gnueabihf-c++* ccache -s 显示状态 ccache -c means clean up ccache -C means clear all
4.设置环境变量
export PATH=/usr/local/arm/toolchain/bin-ccache:/usr/local/arm/toolchain/bin:$PATH export CROSS_COMPILE=arm-linux-gnueabihf- export ARCH=arm
编译uboot时出现的问题
lib/asm-offsets.c:1: error: bad value (armv5) for -march= switch
原因是没有指定交叉编译工具链。设置环境变量,或者make时带上CROSS_COMPILE参数。如make CROSS_COMPILE=arm-none-linux-gnueabi-,注意compile不是compiler
修改环境变量,把交叉编译器的路径加入到PATH。
方法一:修改/etc/bash.bashrc文件(此文件只对当前用户适用)
在最后加上export PATH=
$sudo gedit /etc/bash.bashrc export PATH=/usr/local/arm/toolchain/bin-ccache:/usr/local/arm/toolchain/bin:$PATH
方法二:修改/etc/profile文件(此文件属于系统级别的环境变量,设置在里面的东西对所有用户适用
$sudo gedit /etc/profile export PATH=/usr/local/arm/toolchain/bin-ccache:/usr/local/arm/toolchain/bin:$PATH
方法三:修改/etc/environment文件
$sudo gedit /etc/environment export PATH=...............
http://blog.csdn.net/goodwillyang/article/details/39779183