Ubuntu 16.04上安装arm-linux-gcc-4.4.3

Ubuntu 16.04上安装arm-linux-gcc-4.4.3

 

一、首先下载arm-linux-gcc-4.4.3-20100728.tar安装包,安装包地址:

 

百度云链接:https://pan.baidu.com/s/13_DnjmfYaugvuuhK6Owt5Q 
提取码:f54e

 

二、解压安装包

 

sudo tar -zxvf arm-linux-gcc-4.4.3-20100728.tar.gz -C /

 

注意C后面有一个空格,这样解压完成后的文件在:/opt/FriendlyARM/toolschain/4.4.3路径下

 

三、在/usr/local目录下新建arm目录,并拷贝/opt/FriendlyARM/toolschain/路径下的4.4.3到arm目录:

 

cd /usr/local

 

sudo mkdir arm

 

sudo chmod 777 arm

 

sudo cp -r /opt/FriendlyARM/toolschain/4.4.3 /usr/local/arm

 

四、修改环境变量,把arm-linux-gcc添加到PATH中:

 

第二种办法最有效,不管哪种办法都要先取得root权限

 

 

方法一:修改/etc/bash.bashrc文件,此文件只对当前用户适用

修改之前先root权限

sudo -s或sudo su -

 

sudo gedit /etc/bash.bashrc

 

在最后加上export PATH=$PATH:/usr/local/arm/4.4.3/bin

 

保存,退出,然后刷新环境变量使其生效:

 

source /root/.bashrc

 

方法二:修改/etc/profile文件,此文件对所有用户适用

 

sudo gedit /etc/profile

 

在最后加上export PATH=$PATH:/usr/local/arm/4.4.3/bin

 

保存,退出,然后刷新环境变量使其生效:

 

source /etc/profile

 

方法三:修改/etc/environment文件

 

sudo gedit /etc/environment

 

在最后加上:/usr/local/arm/4.4.3/bin

 

保存,退出,然后重启系统

 

五、检查环境变量添加是否正确

 

echo $PATH

 

如果可以显示/usr/local/arm/4.4.3/bin,那么环境变量添加成功

 

六、检查arm-linux-gcc是否安装正确:

 

arm-linux-gcc -v

 

会出现错误:

 

/usr/local/arm/arm-linux-gcc-4.4.3/bin/arm-linux-gcc: 15: exec: /usr/local/arm/arm-linux-gcc-4.4.3/bin/.arm-none-linux-gnueabi-gcc: not found

 

解决上面问题的方法:

 

因为你使用的是64位系统,但是编译工具是32位,需要安装32位支持库

使用命令:sudo apt-get install lib32ncurses5 lib32z1

 

安装完,再次测试命令:arm-linux-gcc -v,就可以成功了。

 

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)

 

显示已经安装成功。

 

七、编写测试程序,用arm-linux-gcc编译

 

建立一个空文档,编写以下代码,并保存为test.c:

 

#include

 

void main(void)

 

{

 

  printf("%s","Hello World!\n");

 

}

 

使用命令: arm-linux-gcc main.c -o main

 

可能出现:

 

/usr/local/arm/arm-linux-gcc-4.4.3/bin/../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

 

解决上面问题的方法:

 

使用命令:sudo apt-get install lib32stdc++6

 

安装完,再次执行命令:arm-linux-gcc main.c -o main,全部完成

你可能感兴趣的:(专业)