ubuntu 安装arm-linux-gcc 4.4.3交叉编译器

系统版本:Ubuntu 18.04.1 LTS

编译器资源:arm-linux-gcc 4.4.3.tar.gz(网上搜索有资源可下载)

用windows下载arm-linux-gcc 4.4.3.tar.gz压缩包并放到samba服务的共享文件夹,这里如果windows不能访问共享文件夹的话检查下smb.conf文件的配置,是否有writeable = yes,还有就是目录的权限也要记得修改(具体网上有很多博客介绍了)。

进入ubuntu,从Ubuntu进入共享文件夹,将压缩包移动至/usr/local文件夹下(登陆root进行一系列操作)

mv  [源文件] [目标文件/目标文件夹]

将压缩包解压至目前目录(/usr/local)下

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

扫描二维码关注公众号,回复: 4921116 查看本文章

修改环境变量

vi   /etc/profile 

在profile文件末尾添加下列内容,将arm-linux-gcc 4.4.3的bin目录下的文件的文件路径添加到PATH变量

export PATH=$PATH:/usr/local/opt/FriendlyARM/toolschain/4.4.3/bin/(这里要看bin文件夹的具体位置,我解压后的路径是这个)

让环境变量生效

source /etc/profile(用root权限操作)

检查环境变量是否配置成功

echo $PATH

检查编译器环境是否搭建成功

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) 

如果显示:命令未找到

则输入下列命令

sudo apt-get install ia32-lib
sudo sudo apt-get install lib32ncurses5
sudo apt-get install lib32z1

验证功能

新建hello.c

vi hello.c

输入文件内容

#include <stdio.h>

int main()
{
   printf("hello world=====\n");
   return 0;
}

保存后退出,输入命令

arm-linux-gcc hello.c -o hello

若提示 error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
 

 则输入以下命令,安装相应的库:

sudo apt-get install glibc.i686
sudo apt-get install lib32stdc++6

 

这里简述下gcc 和 arm-linuxgcc两者的区别

GCC :The GNU Complier Collection,是一套由GNU开发的编译器集,支持C、C++、Ada、Objective C等许多语言。

GCC编译后的可执行文件可直接在linux系统上运行

而arm-linux-gcc是基于ARM目标机的交叉编译软件,其生成的可执行文件不能直接在linux系统上运行,但可下载到目标机中执行。

猜你喜欢

转载自blog.csdn.net/yhl_sophia/article/details/86233075