Chinaunix首页 | 论坛 | 博客
  • 博客访问: 272301
  • 博文数量: 21
  • 博客积分: 510
  • 博客等级: 下士
  • 技术积分: 545
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-05 12:32
文章分类
文章存档

2013年(3)

2012年(13)

2011年(5)

分类: LINUX

2013-11-19 21:28:27

关于linaro参见其官网
gcc-linara源码可以从这个网址下载 
gcc的编译依赖于几个库,GMP,MPFR,MPC,首先需要编译他们,从 下载这几个库的源代码。
1. 编译GMP 
解压后使用标准的GNU源码编译方法
./configure  --prefix=/home/jqzeng/tools/gmp
make
make install
--host指定的是编译所用主机类型
2. 编译MPFR
./configure  --prefix=/home/jqzeng/tools/mpfr --with-gmp=/home/jqzeng/tools/gmp
make && make install
3.编译MPC  
./configure --prefix=/home/jqzeng/tools/mpc --with-gmp=/home/jqzeng/tools/gmp --with-mpfr=/home/jqzeng/tools/mpfr
make && make install
4.编译isl 下载地址 
./configure --prefix=/home/jqzeng/tools/isl --with-gmp-prefix=/home/jqzeng/tools/gmp
make && make install
5.编译cloog  下载地址 
./configure  --prefix=/home/jqzeng/tools/cloog --with-gmp-prefix=/home/jqzeng/tools/gmp
make && make install
6.编译libelf   下载地址
 ./configure --prefix=/home/jqzeng/tools/libelf
make && make install
7.编译binutils 
./configure --prefix=/usr/local/linaro-gcc --with-sysroot=/usr/local/arm-linux/arm-linux-gnueabi/libc --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --with-gmp=/home/jqzeng/tools/gmp --with-isl=/home/jqzeng/tools/isl  --with-mpfr=/home/jqzeng/tools/mpfr --with-mpc=/home/jqzeng/tools/mpc
make 
sudo make install
加上--with-sysroot是很重要的,否则编译gcc的时候会出现“ld:this linker was not configured to use sysroots”的错误。
8. 安装内核头文件
解压内核并cd到源码目录,执行下面的命令构建sanitized 版本内核头文件。
make ARCH=arm headers_check
 sudo make ARCH=arm INSTALL_HDR_PATH=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr headers_install
9. 编译c库头文件  eglibc  
mkdir build

CC=gcc ../configure  --prefix=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr --build=x86_64-linux-gnu --host=arm-linux-gnueabi --with-header=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr/include 
sudo make install-headers
注意这里设置的--host是目标板,与其他地方的不一样。
内核头文件和C库头文件放在sysroot下,消除缺少头文件的问题“The directory that should contain system headers does not exist” 
10.编译用于编译glibc的gcc
解压gcc-linara,cd到源码目录
mkdir build
cd build
../gcc-linaro-4.8-2013.10/configure --prefix=/usr/local/arm-linux --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --with-gmp=/home/jqzeng/tools/gmp
 --with-mpfr=/home/jqzeng/tools/mpfr --with-mpc=/home/jqzeng/tools/mpc --with-isl=/home/jqzeng/tools/isl --with-cloog=/home/jqzeng/tools/cloog
--with-libelf=/home/jqzeng/tools/libelf --enable-languages=c,c++,fortran --enable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard
--enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-gold  --enable-c99
--enable-long-long --with-mode=thumb --with-sysroot=/usr/local/linaro-gcc/arm-linux-gnueabi/libc --with-local-prefix=/usr/local/linaro-gcc/arm-linux-gnueabi/libc
make -j4


到这里配置出错了
checking for version 0.10 of ISL... no
checking for version 0.11 of ISL... no
checking for version 0.12 of ISL... no
configure: error: Unable to find a usable ISL.  See config.log for details.
打开config.log
configure:5857: checking for version 0.10 of ISL
configure:5876: x86_64-linux-gnu-gcc -o conftest -g -O2 -I/home/jqzeng/tools/isl/include -I/home/jqzeng/tools/gmp/include -I/home/jqzeng/tools/mpfr/include -I/home/jqzeng/tools/mpc/include    -L/home/jqzeng/tools/isl/lib conftest.c  -lisl >&5
configure:5876: $? = 0
configure:5876: ./conftest
./conftest: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
configure:5876: $? = 127
configure: program exited with status 127
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h.  */
| #include
|    #include
| int
| main ()
| {
| if (strncmp (isl_version (), "isl-0.10", strlen ("isl-0.10")) != 0)
|      return 1;
|
|   ;
|   return 0;
| }
configure:5885: result: no
configure:5905: checking for version 0.11 of ISL
configure:5924: x86_64-linux-gnu-gcc -o conftest -g -O2 -I/home/jqzeng/tools/isl/include -I/home/jqzeng/tools/gmp/include -I/home/jqzeng/tools/mpfr/include -I/home/jqzeng/tools/mpc/include    -L/home/jqzeng/tools/isl/lib conftest.c  -lisl >&5
configure:5924: $? = 0
configure:5924: ./conftest
好吧,是加载动态库的时候出问题了。
 sudo vim /etc/ld.so.conf.d/ld.isl.so.conf
将isl的lib库的绝对路径写入ld.isl.so.conf文件中 /home/jqzeng/tools/isl/lib
顺便将tools目录下的其他动态库的路径都加上
执行下面的命令重建/etc/ld.so.cache
sudo ldconfig
重新来一遍配置gcc-linara。
执行make,喝杯咖啡歇会,这是个漫长的过程。
sudo make install

11 编译eglibc
 CC=arm-linux-gnueabi-gcc ../configure  --prefix=/usr/local/arm-linux/arm-linux-gnueabi/libc/ --build=x86_64-linux-gnu --host=arm-linux-gnueabi
--with-header=/usr/local/arm-linux/arm-linux-gnueabi/libc/usr/include --enable-add-ons --with-binutils=/usr/local/arm-linux/bin --enable-shared libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes
make 
sudo make install

好吧,现在工具链已经编译完成,下一步是使用该工具链编译uboot和kernel。





阅读(19951) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~