博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu16.04上安装arm-linux-gcc4.4.3
阅读量:6870 次
发布时间:2019-06-26

本文共 2865 字,大约阅读时间需要 9 分钟。

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

http://www.cr173.com/soft/42654.html

二、解压安装包:

sudo tar -zxvf arm-linux-gcc-4.4.3.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中:

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

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

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 <stdio.h>

void main(void)

{

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

}

输入以下命令:

arm-linux-gcc -o Hello test.c

编译完成后会生成Hello可执行文件,输入以下命令可以查看生成的文件信息:

readelf -h Hello

ELF Header:

  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8334
  Start of program headers:          52 (bytes into file)
  Start of section headers:          4464 (bytes into file)
  Flags:                             0x5000002, Version5 EABI, <unknown>
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         10
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27

可以看到可执行文件的平台为ARM平台。

 

转载于:https://www.cnblogs.com/softhal/p/5699381.html

你可能感兴趣的文章
EJS甘特图控件下载购买地址
查看>>
MST多重生成树协议
查看>>
python 多用户发邮件
查看>>
Python列表copy
查看>>
Spring自定义标签解析与实现
查看>>
Python:itertools模块-groupby
查看>>
合理看待团队的良性冲突
查看>>
Nginx用户认证与域名重定向
查看>>
区块链技术的核心概念
查看>>
linux下磁盘I/O查看
查看>>
JAXB:xml与java对象互转
查看>>
第一章 数组与指针概念剖析
查看>>
centos7部署python3虚拟环境
查看>>
我的友情链接
查看>>
2014-07-18 Java Web的学习(15)-----struts2(1)----XWork中的容器
查看>>
7个示例科普CPU Cache
查看>>
框架汇总
查看>>
我的上半年“手相”-----“奔跑中的2015”
查看>>
mb_substr()----------php
查看>>
[OpenStack] OpenStack Essex - Glance - Image Management
查看>>