Cross compile - scratchbox

来源:互联网 发布:工程中标数据网 编辑:程序博客网 时间:2024/05/01 14:22

前面提到过利用 crosstool 快速编译 cross compiler,对于简单的没有太多外部依赖的程序来说,这已经足够了。但是对于基于 GNU autotools 进行配置编译的软件包来说,常常会因为关联到 HOST 上的外部依赖库文件,因此要求我们先要用 cross compiler 编译这些外部依赖库,然后修改或者配置该软件包的外部关联库的查找路径。另外configure通常会利用小程序检测对应的依赖是否存在,如果是不同体系 cpu 间 cross compile,那么这些小程序将无法在 host 运行。还是有不少工作需要去作。

 

如果利用另外一个工具  scratchbox,那么可以简化上面的流程。

 

scratchbox [1] is a cross-compilation toolkit designed to make embedded Linux applicationdevelopment easier. It provides a full set of tools to integrate and cross-compile an entire Linux distribution.Scratchbox supports cross-compiling for ARM and PowerPC targets. Especially Debian [2] issupported, but Scratchbox has also been used to cross-compile e.g. Slackware for ARM.

Scratchbox provides a sandboxed build environment which offers a controlled set of tools and utilities needed forcross-compilation. It is an environment in which it is easy to assure that the intended versions of libraries, headersand other similar files are used during the build. Most of the higher level software built using GNU Autotools do notcross-compile well in their as-is form, Scratchbox solves this problem by allowing the small test programs (used by theconfigure script to test for availability of features in the environment) to run transparently either using an emulatoror through sbrsh protocol between Scratchbox and actual target device. In practice software configuration and buildingusing Scratchbox is quite identical to how it's done for the desktop.

Scratchbox has been designed to allow multiple application developers work simultaneously on a single host machine.Each developer has his private user account, and all configuration is developer-specific.

This document describes Scratchbox install procedure and how Scratchbox can be used to cross-compile applications toARM target platform.

 

下面简单介绍 scratchbox 的安装。http://www.scratchbox.org/documentation/user/scratchbox-1.0/html/installdoc.html

 

这里我们只安装下面三个 package

 

Base (required):
    * scratchbox-core - environment, common tools and host compiler
    * scratchbox-libs - libraries required by core, devkits and toolchains

; 解压到 /scratchbox
[root@webhost tmp]# tar zxf scratchbox-core-1.0.17-i386.tar.gz -C /
[root@webhost tmp]# tar zxf scratchbox-libs-1.0.17-i386.tar.gz -C /
[root@webhost tmp]# tar xzf scratchbox-toolchain-host-gcc-1.0.17-i386.tar.gz -C /

[root@webhost tmp]# cd /scratchbox/
[root@webhost scratchbox]# ls -la
total 56
drwxr-xr-x   9 root root 4096 Oct 14 12:16 .
drwxr-xr-x  11 root root 4096 Oct 14 12:14 ..
drwxr-xr-x   4 root root 4096 Oct 14 12:16 compilers
drwxr-xr-x   2 root root 4096 Aug 27 21:09 doc
drwxr-xr-x   5 root root 4096 Aug 27 23:07 etc
drwxr-xr-x   4 root root 4096 Aug 27 21:08 host_shared
-rwxr-xr-x   1 root root 7165 Aug 27 21:07 login
drwxr-xr-x   3 root root 4096 Aug 27 23:07 packages
-rw-r--r--   1 root root   42 Aug 27 21:07 README
-rwxr-xr-x   1 root root 1414 Aug 27 21:07 run_me_first.sh
drwxr-xr-x   2 root root 4096 Aug 27 21:27 sbin
drwxr-xr-x  11 root root 4096 Oct 14 12:16 tools

; setup Scratchbox
[root@webhost /]# /scratchbox/run_me_first.sh
Do you want to use sudo mode? [yes/no] (no):
Give the name of the scratchbox group (sbox):
The group 'sbox' does not seem to exist!
Would you like me to create the group 'sbox' for you? [yes/no] (yes):
Creating group "sbox"...
Stopping Scratchbox: umount, binfmt_misc.
Starting Scratchbox: binfmt_misc, mount.

Now you should add one or more users with /opt/scratchbox/sbin/sbox_adduser

 

; 为 scratchbox 增加用户,该用户可以是你的普通 linux 帐号

[root@webhost /]# /scratchbox/sbin/sbox_adduser gang
Add user gang to group 'sbox'? [yes/no] (yes):
Scratchbox user account for user gang added


; 用自己的 linux 帐号登录 scratchbox
[root@webhost /]# su - gang
-bash-3.00$ /scratchbox/login

You dont have active target in scratchbox chroot.
Please create one by running "sb-menu" before continuing


Welcome to Scratchbox, the cross-compilation toolkit!

Use 'sb-menu' to change your compilation target.
See /scratchbox/doc/ for documentation.

sb-conf: No current target
[sbox-: ~] >

; 用 sb-menu 创建一个 target,因为前面我们只安装了 host-gcc toolchain,因此这里也只能选择我们需要创建的 target 对应这个 toolchain。

; 后面我们可以自己编译符合要求的新的 toolchain

 

;  traget 建立后,我们可以测试一下安装

 

[sbox-MYTARGET: ~] > tar xfz /scratchbox/packages/hello-world.tar.gz
[sbox-MYTARGET: ~] > cd hello-world
[sbox-MYTARGET: ~/hello-world] > ./autogen.sh
[sbox-MYTARGET: ~/hello-world] > make[sbox-MYTARGET: ~/hello-world] > file hello
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 2岁着凉了呕吐怎么办 2岁宝宝着凉呕吐怎么办 两岁宝宝偏矮怎么办 2岁宝贝吐没精神怎么办 11个月的宝宝吐怎么办 二岁的宝宝吐了怎么办 十个月小孩吐了怎么办 10个月宝宝呕吐怎么办 小孩又拉又吐的怎么办 小孩子不吃饭呕吐拉肚子怎么办 小孩发烧后又吐怎么办 11个月宝宝吐了怎么办 11个月宝宝拉肚子怎么办 2岁宝宝反复呕吐怎么办 1岁半幼儿拉肚子怎么办 宝宝打嗝呕吐胃难受怎么办 3岁宝宝发烧还吐怎么办 孩子喝水都吐怎么办啊 宝宝吃多了呕吐怎么办 3岁宝宝吐怎么办才好 儿童受凉肚子疼发热呕吐怎么办 两岁宝宝半夜呕吐怎么办 两岁宝宝吐了怎么办 2岁宝宝发烧吐怎么办 2岁多宝宝呕吐是怎么办 2周岁宝宝中暑了怎么办 2岁半宝宝着凉呕吐怎么办 3岁宝宝吐了几次怎么办 一岁宝宝恶心吐怎么办 9个月宝宝一直吐怎么办 晚上冻着了呕吐怎么办 2岁宝宝一直吐怎么办 两岁宝宝门牙龋齿怎么办 两岁宝宝得龋齿怎么办 两岁宝宝长龋齿怎么办 宝宝2岁不吃饭怎么办 两岁宝宝总是吐怎么办 3岁儿童受凉呕吐怎么办 两岁宝宝四天没拉大便怎么办 两岁宝宝发烧吐怎么办 四岁宝宝吐了怎么办啊