arm ubuntu 安装java,Ubuntu 16.04上安装arm-linux-gcc-4.4.3

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

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

二、解压安装包:

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

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,

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平台。

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值