zoukankan      html  css  js  c++  java
  • 利用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:

    1. Download crosstool-ng from the project web site. I’ve used version 1.15.2 as that was the latest when I wrote this.
    2. 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.
    3. Run make and sudo make install.
    4. 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:

    1. 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.
    2. Run ct-ng menuconfig. You should see the ct-ng configuration menu.
    3. Go into Paths and misc options. Enable Try features marked as EXPERIMENTAL. This is important.
    4. 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}.
    5. Go back to the main menu and select Target options.
    6. Change the Target architecture to arm. Leave Endianness set to Little endian and Bitness set to 32-bit.
    7. Go back to the main menu and select Operating system (skip Toolchain options, the defaults are fine).
    8. Change Target OS to linux.
    9. Go back to the main menu and select Binary utilities.
    10. Change binutils version to 2.21.1a or whichever is the latest that isn’t marked as experimental. Probably unnecessary but I prefer this.
    11. Go back to the main menu and select C compiler.
    12. Enable the Show Linaro versions (EXPERIMENTAL) option.
    13. 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.
    14. All the other settings are fine left at their default values. Exit the configuration tool and save your changes.
    15. Run ct-ng build.
    16. Go away and make a coffee, etc… This bit will take some time.
    17. 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.
    18. 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.
  • 相关阅读:
    git本地仓库基本使用(Repository)
    归途
    PowerDesigner逆向工程导入MYSQL数据库总结(转载)
    协程
    os.path.split 和 os.path.splitext
    转载)Linux平台下安装 python 模块包
    Java之map使用方法
    Java学习(JDBC java连接数据库)
    python -- 找出列表list中的重复元素
    JAVA打印变量类型
  • 原文地址:https://www.cnblogs.com/tobeprogramer/p/4739164.html
Copyright © 2011-2022 走看看