centos安装arm-linux-gcc4.4.3相关
来源:互联网 发布:手机淘宝怎么退款过程 编辑:程序博客网 时间:2024/05/16 14:58
(注:首先需要明确需要安装centos系统的位数,即是32位的还是64位的。)
1、下载并解压文件:下载arm-linux-gcc-4.4.3.tgz到任意的目录下,进入这个文件夹
输入命令:# tar xvzf arm-linux-gcc-4.4.3.tgz –C / 【解压文件到 /opt/Friendlyarm/4.4.3 目录】
注意:C后面有个空格,并且C是大写的,它是英文单词“Change”的第一个字母,
在此是改变目录的意思。
在/usr/local/下建立arm的文件夹
输入命令:# mkdir arm 【新建 /usr/local/arm/ 目录】
# chmod 777 arm 【修改此文件夹的权限 ,可用 命令 # cd -ll 查看】
输入命令:# cp -r /opt/Friendlyarm/4.4.3 /usr/local/arm/ 【然后把opt下的4.4.3目录复制到/usr/local下】
2、修改环境变量,把交叉编译器的路径加入到PATH。
方法一:修改/etc/bash.bashrc文件(此文件只对当前用户适用)
输入命令:# gedit /etc/bash.bashrc
在最后加上 export PATH=$PATH:/usr/local/arm/4.4.3/bin
方法二(推荐):修改/etc/profile文件(此文件属于系统级别的环境变量,设置在里面的东西对所有用户适用):
输入命令:# vim /etc/profile
增加路径设置,在末尾添加如下,保存/etc/profile文件:
export PATH=$PATH:/usr/local/arm/4.4.3/bin
方法三:修改/etc/environm:ent文件
输入命令:# gedit /etc/environment
原文件应为 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games“
将其改为 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.4.3/bin"
保存退出即可
关于路径设置问题,可以 用终端逐步寻找,比如 在 终端下cd /usr/local/用TAB键 一直找到/bin
关于环境变量问题:
环境变量是什么?例如path,当要求系统运行一个程序而没有告诉它程序所在的完整路径时,系统除了在当前目录下面寻找此程序外,还应到path中指定的路径去找。用户通过设置环境变量,来更好的运行进程。
如果上面不加入环境变量,要运行arm-linux-gcc这个程序,则每次都要把arm-linux-gcc的完整路径写出来。/usr/local/arm/4.4.3/bin arm-linux-gcc文件名-o输出文件名
这样非常的麻烦,所以加到path里面,让电脑知道这个程序在哪里。
3. 立即使新的环境变量生效,不用重启电脑:
对应方法一:
输入命令:# source /root/.bashrc
对应方法二:
输入命令:# source /etc/profile
方法三立即生效
4. 检查是否将路径加入到PATH:
输入命令:# echo $PATH
显示内容/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.4.3/bin说明已经将交叉编译器的路径加入PATH。至此,交叉编译环境安装完成。
5.测试是否安装成功
输入命令:# arm-linux-gcc -v
若centos为32位系统则会直接安装成功,则会显示如下信息:
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure --build=i386-build_redhat-linux-gnu --host=i386-build_redhat-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.4.3 --with-sysroot=/opt/FriendlyARM/toolschain/4.4.3/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-optspace
Thread model: posix
gcc version 4.4.3 (ctng-1.6.1)
若centos系统为64位时,则会提示一下内容
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
表示没有安装成功,此时则需要做如下操作:
1、在64系统里执行32位程序如果出现/lib/ld-linux.so.2:
bad ELF interpreter: No such file or directory,安装下glic即可 则需要输入命令:# yum install glibc.i686 【 www.2cto.com 】2、如果出现error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory则需要输入命令:# yum install zlib.i6863、如果出现 /libexec/gcc/arm-none-linux-gnueabi/4.4.3/cc1: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
则需要输入命令:# yum -y install libstdc*
另外若当有缺少共享库的报错:
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
解决办法:
1、输入命令:# yum whatprovides libstdc++.so.6
然后会提示哪个安装包有这个库文件如下:
[root@localhost ~]# yum whatprovides libstdc++.so.6
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify,
: versionlock
Loading support for CentOS kernel ABI
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* centosplus: centos.ustc.edu.cn
* contrib: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
libstdc++-4.4.7-3.el6.i686 : GNU Standard C++ Library
Repo : base
Matched from:
Other : libstdc++.so.6
2、然后执行:
输入命令:# yum installlibstdc++-4.4.7-3.el6.i686
搞定!
6.编译Hello World程序,测试交叉工具链
写下下面的Hello World程序,保存为hello.c
#include “stdio.h”
int main()
{
printf("Hello World!\n");
return 0;
}
执行下面的命令:
$ arm-linux-gcc hello.c -o hello
ls下
看到hello执行文件
$ file hello在hello的目录下
可以看到hello: ELF 32-bit LSB executable,ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
这样说明可以在ARM上运行,此时不能在pc上运行
(注:首先需要明确需要安装centos系统的位数,即是32位的还是64位的。)
1、下载并解压文件:下载arm-linux-gcc-4.4.3.tgz到任意的目录下,进入这个文件夹
输入命令:# tar xvzf arm-linux-gcc-4.4.3.tgz –C / 【解压文件到 /opt/Friendlyarm/4.4.3 目录】
注意:C后面有个空格,并且C是大写的,它是英文单词“Change”的第一个字母,
在此是改变目录的意思。
在/usr/local/下建立arm的文件夹
输入命令:# mkdir arm 【新建 /usr/local/arm/ 目录】
# chmod 777 arm 【修改此文件夹的权限 ,可用 命令 # cd -ll 查看】
输入命令:# cp -r /opt/Friendlyarm/4.4.3 /usr/local/arm/ 【然后把opt下的4.4.3目录复制到/usr/local下】
2、修改环境变量,把交叉编译器的路径加入到PATH。
方法一:修改/etc/bash.bashrc文件(此文件只对当前用户适用)
输入命令:# gedit /etc/bash.bashrc
在最后加上 export PATH=$PATH:/usr/local/arm/4.4.3/bin
方法二(推荐):修改/etc/profile文件(此文件属于系统级别的环境变量,设置在里面的东西对所有用户适用):
输入命令:# vim /etc/profile
增加路径设置,在末尾添加如下,保存/etc/profile文件:
export PATH=$PATH:/usr/local/arm/4.4.3/bin
方法三:修改/etc/environm:ent文件
输入命令:# gedit /etc/environment
原文件应为 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games“
将其改为 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.4.3/bin"
保存退出即可
关于路径设置问题,可以 用终端逐步寻找,比如 在 终端下cd /usr/local/用TAB键 一直找到/bin
关于环境变量问题:
环境变量是什么?例如path,当要求系统运行一个程序而没有告诉它程序所在的完整路径时,系统除了在当前目录下面寻找此程序外,还应到path中指定的路径去找。用户通过设置环境变量,来更好的运行进程。
如果上面不加入环境变量,要运行arm-linux-gcc这个程序,则每次都要把arm-linux-gcc的完整路径写出来。/usr/local/arm/4.4.3/bin arm-linux-gcc文件名-o输出文件名
这样非常的麻烦,所以加到path里面,让电脑知道这个程序在哪里。
3. 立即使新的环境变量生效,不用重启电脑:
对应方法一:
输入命令:# source /root/.bashrc
对应方法二:
输入命令:# source /etc/profile
方法三立即生效
4. 检查是否将路径加入到PATH:
输入命令:# echo $PATH
显示内容/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.4.3/bin说明已经将交叉编译器的路径加入PATH。至此,交叉编译环境安装完成。
5.测试是否安装成功
输入命令:# arm-linux-gcc -v
若centos为32位系统则会直接安装成功,则会显示如下信息:
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure --build=i386-build_redhat-linux-gnu --host=i386-build_redhat-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.4.3 --with-sysroot=/opt/FriendlyARM/toolschain/4.4.3/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-optspace
Thread model: posix
gcc version 4.4.3 (ctng-1.6.1)
若centos系统为64位时,则会提示一下内容
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
表示没有安装成功,此时则需要做如下操作:
1、在64系统里执行32位程序如果出现/lib/ld-linux.so.2:
另外若当有缺少共享库的报错:
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
解决办法:
1、输入命令:# yum whatprovides libstdc++.so.6
然后会提示哪个安装包有这个库文件如下:
[root@localhost ~]# yum whatprovides libstdc++.so.6
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify,
: versionlock
Loading support for CentOS kernel ABI
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* centosplus: centos.ustc.edu.cn
* contrib: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
libstdc++-4.4.7-3.el6.i686 : GNU Standard C++ Library
Repo : base
Matched from:
Other : libstdc++.so.6
2、然后执行:
输入命令:# yum installlibstdc++-4.4.7-3.el6.i686
搞定!
6.编译Hello World程序,测试交叉工具链
写下下面的Hello World程序,保存为hello.c
#include “stdio.h”
int main()
{
printf("Hello World!\n");
return 0;
}
执行下面的命令:
$ arm-linux-gcc hello.c -o hello
ls下
看到hello执行文件
$ file hello在hello的目录下
可以看到hello: ELF 32-bit LSB executable,ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
这样说明可以在ARM上运行,此时不能在pc上运行
Linux环境变量文件environment, profile, bashrc含义
转自:http://www.th7.cn/system/lin/201508/127503.shtml
(1)/etc/profile: 此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置。
(2)/etc/environment:是设置整个系统的环境,而/etc/profile是设置所有用户的环境,前者与登录用户无关,后者与登录用户有关。
(3)/etc/bashrc: 为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取。
(4)~/.bash_profile: 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。
(5)~/.bashrc: 该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取。
- centos安装arm-linux-gcc4.4.3相关
- arm-linux-gcc4.4.3安装
- ubuntu11.04安装arm-linux-gcc4.4.3
- ubuntu12.04安装gcc、gdb和arm-Linux-gcc4.4.3
- Ubuntu16.04上安装arm-linux-gcc4.4.3
- ubuntu15.04安装arm-linux-gcc4.5.1
- linux(Centos)下编译安装gcc4.8.2
- ubuntu11.10 下 arm-linux-gcc4.4.3
- ubuntu 下 arm-linux-gcc4.4.3
- ubuntu11.10 下 arm-linux-gcc4.4.3
- centos 安装gcc4.8
- centos安装GCC4.8.2
- Ubuntu14.04 64位 安装arm-linux-gcc4.5.1 总结
- CentOS离线安装gcc4.8.2
- CentOS离线安装gcc4.8.2
- CentOS 6.6安装gcc4.8.2
- CentOS离线安装gcc4.8.2
- CentOS 6.6安装gcc4.8.2
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- tab切换效果(小栗子)
- Gradle学习整理
- 段(Segment) 的控制策略
- Linux入门:vim鼠标不能右键粘贴、跨系统复制粘贴
- centos安装arm-linux-gcc4.4.3相关
- 监听软键盘的收起和弹出
- Android 开源项目源码解析 -->公共技术点之 Android 动画基础(十七)
- Linux命令-7:mv(move(rename))命令
- 齐次坐标的理解
- 学习Java--cp1
- USACO-1.4.3-Mother's Milk
- 第一天
- 国内一线互联网公司内部面试题库