Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1524559
  • 博文数量: 290
  • 博客积分: 3468
  • 博客等级: 中校
  • 技术积分: 3461
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-28 22:21
文章分类

全部博文(290)

文章存档

2016年(13)

2015年(3)

2014年(42)

2013年(67)

2012年(90)

2011年(75)

分类: 嵌入式

2016-04-26 17:53:03

使用scratchbox2建立交叉编译环境,使交叉编译不再烦人。。。。。

os:ubuntu 12.04.4 x64

1. 安装相关工具
sudo apt-get install debootstrap scratchbox2
sudo apt-get install qemu-user-static

mkdir rootfs 
cd rootfs

2. 下载debian 文件系统并安装
sudo debootstrap --verbose --arch mipsel --foreign stable `pwd`

cp /usr/bin/qemu-mipsel-static usr/bin

chroot . /bin/bash
/debootstrap/debootstrap --second-stage 

3. 建立交叉编译用环境
sb2-init ls1c /opt/CodeSourcery/mipsel-none-linux-gnueabi/bin/mipsel-none-linux-gnueabi-gcc
sudo sb2 或 sudo sb2 -t ls1c 

4. 例子
[SB2 simple ls1c ] root ~ $ gcc hello.c
[SB2 simple ls1c ] root@vm ~ $ file a.out 
a.out: ELF 32-bit LSB executable, MIPSEL, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=0xd18141915ced466188d07dfd1a862a5d82d9de73, not stripped
[SB2 simple ls1c ] root@vm ~ $ ./a.out 
hello, world

5. 说明 
其中rootfs为目标板文件系统的目录,debootstrap会在里面安装相关的文件。
ls1c为自己取的名字,可以自己命名。gcc参数需填整完整的路径。
更详细的参数说明见sb2-init 帮助
如果觉得文件系统过大可以考虑用debian embedded 系统。

6. 参考文档:
http://www.cnblogs.com/qiaoqiao2003/p/3738552.html
http://blog.csdn.net/dotmonkey/article/details/6952460

阅读(2457) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~