Ubuntu arm-linux-gcc 安装

来源:互联网 发布:网络捕鱼赌博游戏平台 编辑:程序博客网 时间:2024/06/06 07:18

最近安装了arm-linux-gcc ,我的环境是 unt9.10,网上很多资料,但是感觉讲的很复杂,我的安装如下:
1、下载arm-linux-gcc-4.1.1
2、在/usr/local/arm下解压它(arm文件夹是自己新建的)
3、设置路径;在终端下输入gedit /etc/profile  在最后一行写上如下(红色)内容,其它保持不变,并保存。
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
     if [ -f /etc/bash.bashrc ]; then
    . /etc/bash.bashrc
     fi
  else
     if [ "`id -u`" -eq 0 ]; then
          PS1="#"
          else
          PS1="$"
     fi
  fi
 fi
export PATH=/usr/local/arm/4.1.1/bin:$PATH
umask 022

4、使环境变量生效,在终端输入如下命令  source /etc/profile 在回车
5、输入arm-linux-gcc -v  查看安装情况如下:

Using built-in specs.
Target: arm-iwmmxt-linux-gn?i
Configured with: /home2/yfw/toolchain/toolchain-2007-06-13/build/arm-iwmmxt-linux-gn?i/gcc-4.1.1-glibc-2.5/gcc-4.1.1/configure --target=arm-iwmmxt-linux-gn?i --host=i686-host_pc-linux-gnu --prefix=/home2/yfw/toolchain/2008-11-03/arm-iwmmxt-linux-gn?i --with-cpu=iwmmxt --with-float=soft --enable-cxx-flags=-msoft-float --with-headers=/home2/yfw/toolchain/2008-11-03/arm-iwmmxt-linux-gn?i/arm-iwmmxt-linux-gn?i/incl e --with-local-prefix=/home2/yfw/toolchain/2008-11-03/arm-iwmmxt-linux-gn?i/arm-iwmmxt-linux-gn?i --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-lang ges=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.1.1

6、编写hello.c 程序,测试一下。
#incl e<stdio.h>
int main()
{
printf("i love china\n");
return 0;
}
保存名为hello.c
7、arm-linux-gcc -o hello hello.c 一下,发现该目录下生成一个hello.out可执行文件
8、查看文件属性,输入 file hello.out ,显示如下内容
hello.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped
看到红色的ARM没,代表已经生成了能在ARM平台上运行的可执行文件,
9、到此就结束
/********************************************************************************************************************************************************/
隔了十几天,我再来使用arm-linux-gcc指令的时候,出现了一点状况,找不到这个指令,当时还急了,但是后来再找到这篇文章,发现只要将第4步,也即 source /etc/profile重新执行一遍使环境变量重新生效就可以了
/********************************************************************************************************************************************************/
0 0
原创粉丝点击