I8320的limo开发准备工作:在Debian上使用scratchbox搭建交叉编译环境

来源:互联网 发布:思途cms 编辑:程序博客网 时间:2024/05/16 17:52

    交叉编译,就是在A平台上编译在B平台上运行的程序。比如我就是在Debian上编译将在I8320平台上运行的程序。 

    参照limo开发元老Euzen的文章搭建环境,  http://hi.baidu.com/euzen/blog/item/2b02a3d883a03e6bd1164e53.html

Euzen在前面安装scratchbox部分已经讲的满仔细了,完全按照他写的进行即可。在最后配置编译器的部分,他的文章让参考http://www.scratchbox.org/wiki/ForeignToolchains这个页面。我在这部分的工作走了不少弯路,所以就把这里的小小的经验分享一下。

     注意:在"ForeignToolchains"这个页面,实际上要先参照http://www.scratchbox.org/wiki/Toolchains页面先进行三步设置,也就是常规的Toolchain也都需要进行的设置。忽略这点,后面就不会顺利。

    1.确认Scratchbox 已经安装成功。看看能否能登陆进入。

        cd /scratchbox

        ./login

      此时可能会有提示信息

            Host kernel has vdso support (which is uncompatible with SB)
           You can fix this with either:
           echo 0 > /proc/sys/vm/vdso_enabled
           or
           add 'vdso=0' to the kernel parameters

      那么切换到root用户,运行echo 0 > /proc/sys/vm/vdso_enabled即可

     

      再次运行./login,如果出现提示信息

           ERROR: Scratchbox is not properly set up!
      那么切换到root用户,运行/scratchbox/sbin/sbox_ctl start 启动sbox即可

 

    再次运行./login,如果看到提示信息

       Welcome to Scratchbox, the cross-compilation toolkit!
    说明你已经正确安装了sbox并且已经登录进来了。

 

    现假设我的debian用户名是myusername。

   2.让/scratchbox目录及子目录对myusername所在的组有写权限。

    额外说明:scratchbox似乎要求被安装到/scratchbox目录。如果不愿意装到这里,至少也要在这个位置建立符号连接指向真正安装的位置。

  3.登录到sbox后,使用sb-menu命令,根据随后的向导编辑期望的编辑target,即程序将运行的B平台的一些信息。

    进入Setup菜单->

    new target菜单->

    输入新target的名字->

    选择compiler(如果只解压了一个toolchain,这里也应该只有一项)->

    选择devkits,选择cputransp和debian-etch,上部会说明已经选择的devkits是cputransp和debian-etch,就可继续->

    选择cpu-transparency method(按我的尝试,必须选择qemu-arm-cvs-m,这点很重要!!!!)->

    Do you wish to extract a rootstrap on the target选择否->

    Do you wish to install files into the target选择是->

    Install Files To target我是选择了全部->

    Do you wish to select the target选择是,则今后用sbox编辑的目标平台就是它了。

  4.得到sb-toolchain-extras

    通过darcs get --set-scripts-executable http://scratchbox.org/repos/1.0/sb-toolchain-extras

    如果darcs还没安装,就apt-get intall darcs即可

    这一步会在/home/myusername/sb-toolchain-extras目录下下载一些东西。

  5.使用配置工具配置sbox编译

       cd /scratchbox/compilers/your-cool-compiler

       your-cool-compiler就是你解压的toolchain的目录

       ~/sb-toolchain-extras/confhelper/create_toolchain_conf.py自动配置

       如果没有输出错误信息之类的,就可以用下来命令将该配置保存到arm-mycoolhacks.conf文件中。

       ~/sb-toolchain-extras/confhelper/create_toolchain_conf.py > ~/sb-toolchain-extras/meta/alien-tc/arm-mycoolhacks.conf

  6.安装辅助工具

    cd  ~/sb-toolchain-extras

    make CONFIG=meta/alien-tc/arm-mycoolhacks.conf -C meta/alien-tc all-sums

    make CONFIG=meta/alien-tc/arm-mycoolhacks.conf -C meta/alien-tc

    7.测试环境

      从http://scratchbox.org/repos/1.0/scratchbox下载所有的测试文件,放在/scratchbox下。

    进入/scratchbox目录,运行./run.sh,可以把所有测试跑一遍。

    如果没有提示错误信息,交叉编译环境就算ok了。

 

    我在这一步并没完全跑过。

    把test-libtoolgcc.sh中最后两行改为

      libtool --tag=CC --mode=compile gcc -c "$SOURCE_C"
      libtool --tag=CXX --mode=compile g++ -c "$SOURCE_CPP"

    即增加--tag=CC和--tag=CXX

 

    而在test-libtoolg++.sh中,即使做了类似改动,也没能通过。出错信息如下,希望能有朋友解决了通知我一下。

 

  Running "libtool can link c++ programs" ... FAIL
Output: libtool: link: g++
Errors: /targets/links/arch_tools/bin/libtool: line 676: libtool_args+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: compile_command+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: finalize_command+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: libtool_args+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: compile_command+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: finalize_command+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: libtool_args+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: compile_command+=: command not found
 /targets/links/arch_tools/bin/libtool: line 676: finalize_command+=: command not found
 sbox-arm-none-linux-gnueabi-g++: no input files

 

   不过这一测试没通过,并不影响使用sbox。我不用libtool方式使用g++,而是在scratchbox内直接使用g++,并没有问题。

 

   8.声明:这是我大致的配置过程,但是中间3-6步多次重复,所以如果大家照我的方法来,不一定每步的表现都一样。如果不一样,可以重复3-6步,并换一些sb-menu的设置试试。

原创粉丝点击