码迷,mamicode.com
首页 > 其他好文 > 详细

更换gcc工具链

时间:2019-01-28 21:11:10      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:文件结构   exp   环境变量   sudo   home   pre   snap   toc   gcc   


title: 更换gcc工具链
date: 2019/1/16 19:27:51
toc: true
---

更换gcc工具链

  1. 下载后解压到一个临时目录先看看文件结构

    mkdir tmp
    tar xjf arm-linux-gcc-4.3.2.tar.bz2  -C tmp/
  2. 查看文件结构,可以看到arm-linux-gcc这个工具位置在bin

    cd tmp/usr/local/arm/4.3.2/
    
    book@100ask:~/stu/gcc/tmp/usr/local/arm/4.3.2$ ls
    arm-none-linux-gnueabi  bin  lib  libexec  share
    
    book@100ask:~/stu/gcc/tmp/usr/local/arm/4.3.2$ ls bin/
    arm-linux-addr2line  arm-linux-objdump                 arm-none-linux-gnueabi-gcov
    arm-linux-ar         arm-linux-ranlib                  arm-none-linux-gnueabi-gdb
    arm-linux-as         arm-linux-readelf                 arm-none-linux-gnueabi-gdbtui
    arm-linux-c++        arm-linux-size                    arm-none-linux-gnueabi-gprof
    arm-linux-c++filt    arm-linux-sprite                  arm-none-linux-gnueabi-ld
    arm-linux-cpp        arm-linux-strings                 arm-none-linux-gnueabi-nm
    arm-linux-g++        arm-linux-strip                   arm-none-linux-gnueabi-objcopy
    arm-linux-gcc        arm-none-linux-gnueabi-addr2line  arm-none-linux-gnueabi-objdump
    arm-linux-gcc-4.3.2  arm-none-linux-gnueabi-ar         arm-none-linux-gnueabi-ranlib
    arm-linux-gcov       arm-none-linux-gnueabi-as         arm-none-linux-gnueabi-readelf
    arm-linux-gdb        arm-none-linux-gnueabi-c++        arm-none-linux-gnueabi-size
    arm-linux-gdbtui     arm-none-linux-gnueabi-c++filt    arm-none-linux-gnueabi-sprite
    arm-linux-gprof      arm-none-linux-gnueabi-cpp        arm-none-linux-gnueabi-strings
    arm-linux-ld         arm-none-linux-gnueabi-g++        arm-none-linux-gnueabi-strip
    arm-linux-nm         arm-none-linux-gnueabi-gcc
    arm-linux-objcopy    arm-none-linux-gnueabi-gcc-4.3.2
    
  3. 解压到根目录

    sudo tar xjf arm-linux-gcc-4.3.2.tar.bz2 -C /
    
    book@100ask:/usr/local/arm/4.3.2/bin$ ls /usr/local/arm/4.3.2/bin/arm-linux-gcc  -l
    -rwxr-xr-x 1 root root 62 3月  25  2009 /usr/local/arm/4.3.2/bin/arm-linux-gcc
  4. 查看下原来的环境变量

    echo $PATH
    /home/book/bin:/home/book/.local/bin:/opt/slickedit-pro2017/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/gcc-3.4.5-glibc-2.3.6/bin:/snap/bin
  5. 查看下原来的gcc的位置

    book@100ask:/usr/local/arm/4.3.2/bin$ which arm-linux-gcc
    /opt/gcc-3.4.5-glibc-2.3.6/bin/arm-linux-gcc
  6. 添加环境变量/usr/local/arm/4.3.2/bin/,使用:分开

    export PATH=/home/book/bin:/home/book/.local/bin:/opt/slickedit-pro2017/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/arm/4.3.2/bin/
  7. 上述使用export PATH=xxx是临时的,如果需要永久的话,ubuntu下使用

    sudo vi /etc/environment
    
    source /etc/environment
  8. 看下新版本

    arm-linux-gcc -v
    gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)

更换gcc工具链

标签:文件结构   exp   环境变量   sudo   home   pre   snap   toc   gcc   

原文地址:https://www.cnblogs.com/zongzi10010/p/10331602.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!