在RHEL 5平台上安装和配置arm-Linux-gcc 2011-02-2319336035336040 |分类:嵌入式开发环境|选项卡: |大型中小预订。
在linux平台上安装后,配置arm-linux-gcc使其正常运行
一.安装前准备
1,下载和安装arm-linux-gcc
arm-linux-gcc-4.2.1版本可在http://FTP.snapgear.org/pub/snapgear/tools/arm-Linux /此处下载。 最新版本的ARM-Linux-tools
下面的这是来自ARM官方的下载链接http://www.codesourcery.com/GNU _ toolchain s/arm/download.html,选择HOST为IA32 GNU/Linux,然后单击达达但是,前缀是arm-2010.09-51-arm-none-eabi-i686-PC-Linux-GNU,而不是arm-linux-。
2、删除前安装了旧版本的运行
[ root @ localhost~] # RM-RF/opt/arm
3 )解压缩较新版本的arm-linux-gcc-4.4.3。 (添加c后,它将自动解压缩到名为/usr/local/arm/的目录中。 )但是,友好臂将解压缩为/usr/local/arm,如下所示
[ root @ localhost~] # tar-ivxzf/SMB root/arm-Linux-gcc-4.4.3.tar.gz-c /
4 )配置缓冲区,以便arm-linux-gcc命令可以在/usr/local/arm/4.4.3/美丽的机翼下绑定到全局变量,从而可以在任意目录中执行该命令
打开配置文件
[根@ localhost opt ] # VI/etc /配置文件
打开的文件的
#路径管理
if [ '$EUID'='0' ]; 陈真
pathmunge /s美丽的翅膀
pathmunge /usr/s美丽的翅膀
pathmunge /usr/local/s美丽的翅膀
pathmunge /usr/local/arm/4.4.3/美丽的翅膀
fi
或添加到文件末尾
导出路径=$ path :/usr/local/arm/4.4.3 /美丽的翅膀
保存结束
5 )立即启用新的环境变量,无需重新启动电脑
[根@ localhost opt ] # source/etc /配置文件
[root@localhost opt]#
6、检查路径是否添加到PATH中:
[root@localhost opt]# echo $PATH
中有/usr/local/arm/4.4.3/美丽的翅膀,表示已将交叉编译器路径添加到PATH中。 交叉编译环境的安装到此完成。
7、测试安装是否成功
首先,运行find命令以确定arm-linux-gcc的位置
[ root @ localhost~] # find/- name arm-Linux-gcc
/opt/arm/toolschain/4.4.3/美丽的翅膀/arm-linux-gcc
[根@ localhost~] #
可以看到arm-linux-gcc的位置与环境变量中设定的路径一致
接下来检查arm-linux-gcc的版本
[root@localhost美丽的翅膀]# arm-linux-gcc -v
使用内置规格。
target : arm-none-Linux-gnueabi
已配置with :/opt/friendly arm/mini 2440/build-tools chain/working/src/gcc-4.4.3/配置--build=i386-build _ red hat-Linux-GNU-- host=i386-build _ red hat-Linux-GNU-- target=arm--
arm-none-linux-gnueabi//sys-root --enable-languages=c,c++ --disable-multilib --with-arch=armv4t --with-cpu=arm920t --with-tune=arm920t --with-float=soft --with-pkgversion=ctng-1.6.1 --disable-sjlj-exceptions --enable-__cxa_atexit --with-gmp=/opt/FriendlyARM/toolschain/4.4.3 --with-mpfr=/opt/FriendlyARM/toolschain/4.4.3 --with-ppl=/opt/FriendlyARM/toolschain/4.4.3 --with-cloog=/opt/FriendlyARM/toolschain/4.4.3 --with-mpc=/opt/FriendlyARM/toolschain/4.4.3 --with-local-prefix=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99 --enable-long-long --enable-target-optspaceThread model: posix
gcc version 4.4.3 (ctng-1.6.1)
[root@localhost 优美的翅膀]#
可以看到arm-linux-gcc的版本号,至此,arm-linu-gcc已成功安装。
二,测试
1,在终端中编写test.c测试程序
[root@localhost ~]# vi test.c
[root@localhost ~]# arm-linux-gcc test.c -o test
/opt/arm/toolschain/4.4.3/优美的翅膀/../libexec/gcc/arm-none-linux-gnueabi/4.4.3/cc1: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /opt/arm/toolschain/4.4.3/lib/libppl_c.so.2)
/opt/arm/toolschain/4.4.3/优美的翅膀/../libexec/gcc/arm-none-linux-gnueabi/4.4.3/cc1: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /opt/arm/toolschain/4.4.3/lib/libppl.so.7)
[root@localhost ~]#
用以下命令查看
[root@localhost ~]# strings /usr/lib/libstdc++.so.6|grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_FORCE_NEW
[root@localhost ~]#
可以看到libstdc++.so.6的最高版是GLIBCXX_3.4.8,而不是GLIBCXX_3.4.9,因此需要对libstdc++.so.6进行升级
先删除libstdc++.so.6
[root@localhost ~]# rm /usr/lib/libstdc++.so.6
rm:是否删除 符号链接 “/usr/lib/libstdc++.so.6”? y
[root@localhost ~]#
然后将下载的libstdc++.so.6.0.10复制到/usr/lib/目录下面
[root@localhost ~]# cp /smbroot/libstdc++.so.6.0.10 /usr/lib/
[root@localhost ~]#
再建立符号链接
[root@localhost ~]# ln -s /usr/lib/libstdc++.so.6.0.10 /usr/lib/libstdc++.so.6
[root@localhost ~]#
检验是否替换完成
[root@localhost ~]# strings /usr/lib/libstdc++.so.6|grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
[root@localhost ~]#
重新测试交叉编译是否能用
[root@localhost ~]# arm-linux-gcc test.c -o test
[root@localhost ~]#
编译成功,执行
[root@localhost ~]# ./test
bash: ./test: cannot execute 优美的翅膀ary file
[root@localhost ~]
方法二,(参照网上搜来的办法,还没尝试)
下载最新版本glibc-2.13.tar.gz 包含libstdc++.so.6的库,
然后编译安装glibc
下载glibc-linuxthreads
解压
tar -zxvf glibc-2.13.tar.gz
cd glibc-2.13
tar -zxvf ../glibc-linuxthreads-2.3.2.tar.gz
cd ..
./glibc-2.13/configure --prefix=/usr --disable-profile --enable-add-ons --libexecdir=/usr/lib --with-headers=/usr/include
make
make install
注意点:
1、要将glibc-linuxthreads解压到glibc目录下。
2、不能在glibc当前目录下运行configure。
三、工具使用
1,编译工具arm-linux-gcc
例如arm-linux-gcc hello.c -o hello
2,反汇编工具arm-linux-gcc
例如arm-linux-objdump -D -S hello
3,elf文件查看工具arm-linux-readelf
arm-linux-readelf -a hello (查库所有库)
arm-linux-readelf -d hello (查看动态链接库)
参考文章
Tekkaman Ninja 博主的文章在Fedora 下建立 ARM-Linux 交叉编译环境
jzdxmg主的文章crosstool安装详解
*****************************************************************************
运行hello : ./hello
bash: ./hello: cannot execute 优美的翅膀ary file(无法运行的2进制文件,因为生成的是arm下的2进制文件 );