GNU交叉工具链(arm-linux-gcc 3.4.4) 三

导读:
   由于篇幅限制,分了4部分:
   一:http://hi.baidu.com/%CE%DA%D1%BB%C3%F7/blog/item/6246142475b6ab2ad5074264.html
   二:http://hi.baidu.com/%CE%DA%D1%BB%C3%F7/blog/item/88a32787b4ff092bc75cc365.html
   三:http://hi.baidu.com/%CE%DA%D1%BB%C3%F7/blog/item/257bc907d455dacc7a894765.html
   四:http://hi.baidu.com/%CE%DA%D1%BB%C3%F7/blog/item/2c7f1a0830882331e8248866.html
   2.7 编译 gcc 第一阶段
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers$ cd ${SRC}
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ tar jxvf gcc-3.4.4.tar.bz2
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ patch -d gcc-3.4.4 -p1
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ patch -d gcc-3.4.4 -p1
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p BUILD/gcc-3.4.4-stage1
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd BUILD/gcc-3.4.4-stage1/
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ ../../gcc-3.4.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c --with-sysroot=${SYSROOT}
  注意: 不能加上--disable-shared
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ make all-gcc
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ su root
  root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1# make install-gcc
  root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1# exit
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$
   2.8 编译完整的 glibc
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ cd ${SRC}
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p BUILD/glibc-2.3.5
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd BUILD/glibc-2.3.5
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ BUILD_CC=gcc CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar RANLIB=${CROSS_COMPILE}ranlib AS=${CROSS_COMPILE}as LD=${CROSS_COMPILE}ld ../../glibc-2.3.5/configure --prefix=/usr --build=i386-ubuntu-linux --host=arm-unknown-linux-gnu --target=arm-unknown-linux-gnu --without-__thread --enable-add-ons=linuxthreads --with-headers=${SYSROOT}/usr/include
  说明:
  --prefix: 指定安装路径。
  --target: 指定目标平台。
  --host: 指定当前平台。
  --build: 指定编译平台。
  --with-sysroot: 用于指定编译所需要的头文件,及链接库。
  --enable-add-ons: 加入其它的库,如线程库等。
  --enable-languages: 指定gcc所支持的语言。
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ make
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ su root
  root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5# make install_root=${SYSROOT} install
  root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5# exit
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$
   2.9 编译完整的 gcc
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ cd ${SRC}
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p BUILD/gcc-3.4.4
  arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd BUILD/gcc-3.4.4
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$../../gcc-3.4.4/configure --prefix=${PREFIX} --target=${TARGET} --with-sysroot=${SYSROOT} --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --with-softfloat-support=internal --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$ make
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$ su root
  root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4# make install
  root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4# exit
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$
  arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$ arm-linux-gcc -v
  Reading specs from /usr/local/arm/3.4.4/lib/gcc/arm-linux/3.4.4/specsConfigured with: ../../gcc-3.4.4/configure --prefix=/usr/local/arm/3.4.4 --target=arm-linux --with-sysroot=/usr/local/arm/3.4.4/sysroot --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --with-softfloat-support=internal --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
  Thread model: posix
  gcc version 3.4.4
  arm@ubuntu:/usr/local/arm/3.4.4$ tree -L 1
  .
  |-- arm-linux
  |-- bin
  |-- include
  |-- info
  |-- lib
  |-- libexec
  |-- man
  |-- share
  `-- sysroot
  arm@ubuntu:/usr/local/arm/3.4.4$ du -sh
  193M .
  arm@ubuntu:/usr/local/arm/3.4.4/bin$ ls
  arm-linux-addr2line arm-linux-c++filt arm-linux-gcc-3.4.4 arm-linux-nm arm-linux-readelf
  arm-linux-ar arm-linux-cpp arm-linux-gccbug arm-linux-objcopy arm-linux-size
  arm-linux-as arm-linux-g++ arm-linux-gcov arm-linux-objdump arm-linux-strings
  arm-linux-c++ arm-linux-gcc arm-linux-ld arm-linux-ranlib arm-linux-strip
   2.10 测试 gcc,g++
  arm@ubuntu:~$ vi hello_c.c
  #include
  #include
  int main()
  {
  printf("Hello,World~/n");
  return 0;
  }
  arm@ubuntu:~$ vi hello_cpp.cpp
  #include
  using std::cout;
  using std::endl;
  int main()
  {
  cout<<"Hello,World!/n"<
  return 0;
  }
  arm@ubuntu:~$ arm-linux-gcc hello_c.c -o hello_c
  arm@ubuntu:~$ arm-linux-g++ -o hello_cpp hello_cpp.cpp
  arm@ubuntu:~$ tree -L 1
  .
  |-- dev_home
  |-- hello_c
  |-- hello_c.c
  |-- hello_cpp
  `-- hello_cpp.cpp
  1 directory, 4 files
  arm@ubuntu:~$ file hello_c
  hello_c: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped
  arm@ubuntu:~$ file hello_cpp
  hello_cpp: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped

本文转自
http://hi.baidu.com/%CE%DA%D1%BB%C3%F7/blog/item/257bc907d455dacc7a894765.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值