• crosstool-ng-1.22.0搭建开发环境


       

    Ubuntu16.04无法安装libtool,只能在Ubuntu14.04以下版本安装。

    cp 下载/crosstool-ng-1.22.0.tar.bz2 /home/hou/

    tar -xvf crosstool-ng-1.22.0.tar.bz2

    cd crosstool-ng

       

    安装一些必要的软件:

    apt install gperf bison flex texinfo help2man gawk libtool libncurses5-dev

    Make

    ./configure --prefix=/home/hou/arm/crosstool-ng-1.22.0_install

       

    屏幕剪辑的捕获时间: 2016/5/22 11:18

    sudo make install

       

       

    屏幕剪辑的捕获时间: 2016/5/22 11:20

    ~/.bashrc 配置ct-ng命令的环境变量

    目录:

    love-xin :: ~/arm/crosstool-ng-1.22.0_build % ct-ng list-steps

    Available build steps, in order:

    - libc_check_config

    - companion_libs_for_build

    - binutils_for_build

    - companion_libs_for_host

    - binutils_for_host

    - cc_core_pass_1

    - kernel_headers

    - libc_start_files

    - cc_core_pass_2

    - libc

    - cc_for_build

    - cc_for_host

    - libc_post_cc

    - companion_libs_for_target

    - binutils_for_target

    - debug

    - test_suite

    - finish

    Use "<step>" as action to execute only that step.

    Use "+<step>" as action to execute up to that step.

    Use "<step>+" as action to execute from that step onward.

    love-xin :: ~/arm/crosstool-ng-1.22.0_build % ct-ng list-samples

    Status Sample name

    LN config

    MKDIR config.gen

    IN config.gen/arch.in

    IN config.gen/kernel.in

    IN config.gen/cc.in

    IN config.gen/binutils.in

    IN config.gen/libc.in

    IN config.gen/debug.in

    [G..] alphaev56-unknown-linux-gnu

    [G..] alphaev67-unknown-linux-gnu

    [G..] arm-bare_newlib_cortex_m3_nommu-eabi

    [G..] arm-cortex_a15-linux-gnueabi

    [G.X] arm-cortexa5-linux-uclibcgnueabihf

    [G..] arm-cortex_a8-linux-gnueabi

    [G.X] arm-cortexa9_neon-linux-gnueabihf

    [G..] armeb-unknown-eabi

    [G..] armeb-unknown-linux-gnueabi

    [G..] armeb-unknown-linux-uclibcgnueabi

    [G..] arm-unknown-eabi

    [G..] arm-unknown-linux-gnueabi

    [G.X] arm-unknown-linux-musleabi

    [G..] arm-unknown-linux-uclibcgnueabi

    [G.X] arm-unknown-linux-uclibcgnueabihf

    [G..] armv6-rpi-linux-gnueabi

    [G..] armv7-rpi2-linux-gnueabihf

    [G..] avr

    [G..] i586-geode-linux-uclibc

    [G..] i586-mingw32msvc,i686-none-linux-gnu

    [G..] i686-nptl-linux-gnu

    [G.X] i686-w64-mingw32

    [G..] m68k-unknown-elf

    [G..] m68k-unknown-uclinux-uclibc

    [G..] mips64el-n32-linux-uclibc

    [G..] mips64el-n64-linux-uclibc

    [G..] mips-ar2315-linux-gnu

    [G..] mipsel-sde-elf

    [G..] mipsel-unknown-linux-gnu

    [G..] mips-malta-linux-gnu

    [G..] mips-unknown-elf

    [G..] mips-unknown-linux-uclibc

    [G.X] i686-w64-mingw32,nios2-spico-elf

    [G..] powerpc-405-linux-gnu

    [G..] powerpc64-unknown-linux-gnu

    [G..] powerpc-860-linux-gnu

    [G..] powerpc-e300c3-linux-gnu

    [G..] powerpc-e500v2-linux-gnuspe

    [G..] powerpc-unknown-linux-gnu

    [G..] powerpc-unknown-linux-uclibc

    [G..] powerpc-unknown_nofpu-linux-gnu

    [G.X] s390-ibm-linux-gnu

    [G..] s390x-ibm-linux-gnu

    [G..] sh4-unknown-linux-gnu

    [G..] sparc-unknown-linux-gnu

    [G.X] x86_64-w64-mingw32,x86_64-pc-linux-gnu

    [G..] x86_64-unknown-linux-gnu

    [G..] x86_64-unknown-linux-uclibc

    [G.X] x86_64-w64-mingw32

    [G..] xtensa-unknown-linux-uclibc

    L (Local) : sample was found in current directory

    G (Global) : sample was installed with crosstool-NG

    X (EXPERIMENTAL): sample may use EXPERIMENTAL features

    B (BROKEN) : sample is currently broken

    love-xin :: ~/arm/crosstool-ng-1.22.0_build %

    在后续的配置(和编译)之后,可以通过show-tuple,去查看到当前配置的交叉编译器是啥样的

    love-xin :: ~/arm/crosstool-ng-1.22.0_build % ct-ng show-tuple

    arm-cortexa9_neon-linux-gnueabihf

    查看当前有哪些(默认的)示例配置,可以用:

    ct-ng list-samples

    查看单个的某个示例配置的核心参数,用:

    ct-ng show-<sample>

    love-xin :: ~/arm/crosstool-ng-1.22.0_build % ct-ng show-arm-cortexa9_neon-linux-gnueabihf

    IN config.gen/arch.in

    IN config.gen/kernel.in

    IN config.gen/cc.in

    IN config.gen/binutils.in

    IN config.gen/libc.in

    [G.X] arm-cortexa9_neon-linux-gnueabihf

    OS : linux-4.3

    Companion libs : gmp-6.0.0a mpfr-3.1.3 mpc-1.0.3 expat-2.1.0 ncurses-6.0

    binutils : binutils-2.22

    C compilers : gcc | 5.2.0

    Languages : C,C++

    C library : glibc-2.22 (threads: nptl)

    Tools : gdb-7.10

    love-xin :: ~/arm/crosstool-ng-1.22.0_build %

       

       

       

    屏幕剪辑的捕获时间: 2016/5/22 12:34

       

    iTop4412是使用cortex-a9,所以按照这个配置就OK,上面是软件要求。

    可以直接去调用此配置了:

    ct-ng arm-cortexa9-linux-gnueabi

       

       

    屏幕剪辑的捕获时间: 2016/5/22 13:08

    接下来,你就可以去进入配置:

    ct-ng menuconfig

       

    源码包下载保存路径

    Paths and misc options
    (${HOME}/arm/src) Local tarballs directory

    工作路径

    一般使用默认配置

    Paths and misc options
    (${CT_TOP_DIR}/.build) Working directory

    目标安装路径

       

    Paths and misc options
    (${HOME}/arm/x-tools/${CT_TARGET}) Prefix directory

    一些详细的配置请参考网站:

    crosstool-ng详解

       

    src下面主要用到linux、gcc两个安装包,这两个包比较大,可以提前下载好。其它的包自动下载。

       

    配置好后,保存退出。执行ct-ng build编译

       

       

    屏幕剪辑的捕获时间: 2016/5/22 15:06

    编译详细过程:

    ╭─hou@love-xin ~/arm/crosstool-ng-1.22.0_build

    ╰─$ ct-ng build

    [INFO ] Performing some trivial sanity checks

    [INFO ] Build started 20160522.191913

    [INFO ] Building environment variables

    [EXTRA] Preparing working directories

    [EXTRA] Installing user-supplied crosstool-NG configuration

    [EXTRA] =================================================================

    [EXTRA] Dumping internal crosstool-NG configuration

    [EXTRA] Building a toolchain for:

    [EXTRA] build = x86_64-pc-linux-gnu

    [EXTRA] host = x86_64-pc-linux-gnu

    [EXTRA] target = arm-cortexa9_neon-linux-gnueabihf

    [EXTRA] Dumping internal crosstool-NG configuration: done in 0.10s (at 00:08)

    [INFO ] =================================================================

    [INFO ] Retrieving needed toolchain components' tarballs

    [EXTRA] Retrieving 'glibc-libidn-2.22'

    [INFO ] Retrieving needed toolchain components' tarballs: done in 362.72s (at 06:11)

    [INFO ] =================================================================

    [INFO ] Extracting and patching toolchain components

    [INFO ] Extracting and patching toolchain components: done in 2.59s (at 06:13)

    [INFO ] Saving state to restart at step 'libc_check_config'...

    [INFO ] Saving state to restart at step 'companion_libs_for_build'...

    [INFO ] =================================================================

    [INFO ] Installing ncurses for build

    [EXTRA] Configuring ncurses

    [EXTRA] Building ncurses

    [EXTRA] Installing ncurses

    [INFO ] Installing ncurses for build: done in 39.95s (at 06:53)

    [INFO ] Saving state to restart at step 'binutils_for_build'...

    [INFO ] Saving state to restart at step 'companion_libs_for_host'...

    [INFO ] =================================================================

    [INFO ] Installing GMP for host

    [EXTRA] Configuring GMP

    [EXTRA] Building GMP

    [EXTRA] Installing GMP

    [INFO ] Installing GMP for host: done in 47.59s (at 07:42)

    [INFO ] =================================================================

    [INFO ] Installing MPFR for host

    [EXTRA] Configuring MPFR

    [EXTRA] Building MPFR

    [EXTRA] Installing MPFR

    [INFO ] Installing MPFR for host: done in 36.57s (at 08:19)

    [INFO ] =================================================================

    [INFO ] Installing ISL for host

    [EXTRA] Configuring ISL

    [EXTRA] Building ISL

    [EXTRA] Installing ISL

    [INFO ] Installing ISL for host: done in 33.91s (at 08:53)

    [INFO ] =================================================================

    [INFO ] Installing MPC for host

    [EXTRA] Configuring MPC

    [EXTRA] Building MPC

    [EXTRA] Installing MPC

    [INFO ] Installing MPC for host: done in 16.35s (at 09:09)

    [INFO ] =================================================================

    [INFO ] Installing expat for host

    [EXTRA] Configuring expat

    [EXTRA] Building expat

    [EXTRA] Installing expat

    [INFO ] Installing expat for host: done in 7.11s (at 09:16)

    [INFO ] Saving state to restart at step 'binutils_for_host'...

    [INFO ] =================================================================

    [INFO ] Installing binutils for host

    [EXTRA] Configuring binutils

    [EXTRA] Building binutils

    [EXTRA] Installing binutils

    [EXTRA] Installing ld wrapper

    [INFO ] Installing binutils for host: done in 199.40s (at 12:37)

    [INFO ] Saving state to restart at step 'cc_core_pass_1'...

    [INFO ] =================================================================

    [INFO ] Installing pass-1 core C gcc compiler

    [EXTRA] Configuring core C gcc compiler

    [EXTRA] Building gcc

    [EXTRA] Installing gcc

    [EXTRA] Housekeeping for final gcc compiler

    [INFO ] Installing pass-1 core C gcc compiler: done in 538.26s (at 21:46)

    [INFO ] Saving state to restart at step 'kernel_headers'...

    [INFO ] =================================================================

    [INFO ] Installing kernel headers

    [EXTRA] Installing kernel headers

    [EXTRA] Checking installed headers

    [INFO ] Installing kernel headers: done in 11.64s (at 22:16)

    [INFO ] Saving state to restart at step 'libc_start_files'...

    [INFO ] =================================================================

    [INFO ] Installing C library headers & start files

    [EXTRA] Configuring C library

    [EXTRA] Installing C library headers

    [EXTRA] Installing C library start files

    [INFO ] Installing C library headers & start files: done in 23.37s (at 22:54)

    [INFO ] Saving state to restart at step 'cc_core_pass_2'...

    [INFO ] =================================================================

    [INFO ] Installing pass-2 core C gcc compiler

    [EXTRA] Configuring core C gcc compiler

    [EXTRA] Building gcc

    [EXTRA] Installing gcc

    [EXTRA] Housekeeping for final gcc compiler

    [INFO ] Installing pass-2 core C gcc compiler: done in 657.92s (at 34:06)

    [INFO ] Saving state to restart at step 'libc'...

    [INFO ] =================================================================

    [INFO ] Installing C library

    [EXTRA] Configuring C library

    [EXTRA] Building C library

    [EXTRA] Installing C library

    [EXTRA] Configuring C library localedef

    [EXTRA] Building C library localedef

    [EXTRA] Installing C library locales

    [INFO ] Installing C library: done in 861.70s (at 48:47)

    [INFO ] Saving state to restart at step 'cc_for_build'...

    [INFO ] Saving state to restart at step 'cc_for_host'...

    [INFO ] =================================================================

    [INFO ] Installing final gcc compiler

    [EXTRA] Configuring final gcc compiler

    [EXTRA] Building final gcc compiler

    [EXTRA] Installing final gcc compiler

    [EXTRA] Housekeeping for final gcc compiler

    [INFO ] Installing final gcc compiler: done in 902.17s (at 64:39)

    [INFO ] Saving state to restart at step 'libc_post_cc'...

    [INFO ] Saving state to restart at step 'companion_libs_for_target'...

    [INFO ] =================================================================

    [INFO ] Installing expat for target

    [EXTRA] Configuring expat

    [EXTRA] Building expat

    [EXTRA] Installing expat

    [INFO ] Installing expat for target: done in 6.22s (at 66:33)

    [INFO ] =================================================================

    [INFO ] Installing ncurses for target

    [EXTRA] Configuring ncurses

    [EXTRA] Building ncurses

    [EXTRA] Installing ncurses

    [INFO ] Installing ncurses for target: done in 49.44s (at 67:22)

    [INFO ] Saving state to restart at step 'binutils_for_target'...

    [INFO ] Saving state to restart at step 'debug'...

    [INFO ] =================================================================

    [INFO ] Installing cross-gdb

    [EXTRA] Configuring cross-gdb

    [EXTRA] Building cross-gdb

    [EXTRA] Installing cross-gdb

    [EXTRA] Installing '.gdbinit' template

    [INFO ] Installing cross-gdb: done in 197.27s (at 71:44)

    [INFO ] =================================================================

    [INFO ] Installing native gdb

    [EXTRA] Configuring native gdb

    [EXTRA] Building native gdb

    [EXTRA] Installing native gdb

    [INFO ] Installing native gdb: done in 184.36s (at 74:48)

    [INFO ] =================================================================

    [INFO ] Installing gdbserver

    [EXTRA] Configuring gdbserver

    [EXTRA] Building gdbserver

    [EXTRA] Installing gdbserver

    [INFO ] Installing gdbserver: done in 60.28s (at 75:49)

    [INFO ] Saving state to restart at step 'test_suite'...

    [INFO ] Saving state to restart at step 'finish'...

    [INFO ] =================================================================

    [INFO ] Cleaning-up the toolchain's directory

    [INFO ] Stripping all toolchain executables

    [EXTRA] Installing the populate helper

    [EXTRA] Installing a cross-ldd helper

    [EXTRA] Creating toolchain aliases

    [EXTRA] Removing access to the build system tools

    [EXTRA] Removing installed documentation

    [INFO ] Cleaning-up the toolchain's directory: done in 3.83s (at 77:27)

    [INFO ] Build completed at 20160522.203639

    [INFO ] (elapsed: 77:26.35)

    [INFO ] Finishing installation (may take a few seconds)...

    [77:27] / % ╭─hou@love-xin ~/arm/crosstool-ng-1.22.0_build

    ╰─$

    添加环境变量:

    sudo vim ~/.bashrc

    在PATH变量中添加:${HOME}/arm/x-tools/arm-cortexa9_neon-linux-gnueabihf/bin

    刷新:

    source ~/.bashrc

       

       

    屏幕剪辑的捕获时间: 2016/5/22 21:01

       

    love-xin :: ~/arm/crosstool-ng-1.22.0_build » arm-cortexa9_neon-linux-gnueabihf-gcc --version

    arm-cortexa9_neon-linux-gnueabihf-gcc (crosstool-NG crosstool-ng-1.22.0) 5.2.0

    Copyright © 2015 Free Software Foundation, Inc.

    本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;

    包括没有适销性和某一专用目的下的适用性担保。

    love-xin :: ~/arm/crosstool-ng-1.22.0_build »

       

    为了不影响主机看网页、玩游戏,当时设置Ubuntu是2G运行内存,所以时间有点慢,想要快点可以设置大一点。

       

       

       

       

       

       

       

       

       

       

  • 相关阅读:
    dup/dup2函数
    read/write函数
    lseek函数
    流程控制
    vim普通模式
    vim实用技巧1
    python源代码解读
    python变量命名规则
    python之字符串2
    Docker系列文章
  • 原文地址:https://www.cnblogs.com/zhuixinshaonian/p/7509290.html
Copyright © 2020-2023  润新知