2011年12月2日 星期五

install gcc-4.1 under Ubuntu

目前系統gcc版本是4.4.3

nelson@swdev:~/eMbedded/crosstoolchain/crosstool-0.43$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

此版本編譯cross toolchain都會遇到麻煩

像是
http://blog.chinaunix.net/space.php?uid=20543672&do=blog&id=94333
 所提到的
*** buffer overflow detected ***: arm-9tdmi-linux-gnu-ar terminated

所以需要改裝gcc 4.1版本


ubuntu上安裝挺簡單的

sudo apt-get install gcc-4.1

primesw@swdev:~$ sudo apt-get install gcc-4.1
[sudo] password for primesw:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-2.6.32-34-generic linux-headers-2.6.32-34
  linux-headers-2.6.32-34-server
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  cpp-4.1 gcc-4.1-base
Suggested packages:
  gcc-4.1-locales gcc-4.1-multilib gcc-4.1-doc libmudflap0-dev
The following NEW packages will be installed:
  cpp-4.1 gcc-4.1 gcc-4.1-base
0 upgraded, 3 newly installed, 0 to remove and 142 not upgraded.
Need to get 3,360kB of archives.
After this operation, 7,528kB of additional disk space will be used.
Do you want to continue [Y/n]? y
WARNING: The following packages cannot be authenticated!
  gcc-4.1-base cpp-4.1 gcc-4.1
Install these packages without verification [y/N]? y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ lucid/universe gcc-4.1-base 4.1.2-27u                                                                                        buntu1 [209kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ lucid/universe cpp-4.1 4.1.2-27ubuntu                                                                                        1 [2,550kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ lucid/universe gcc-4.1 4.1.2-27ubuntu                                                                                        1 [600kB]
Fetched 3,360kB in 28s (119kB/s)
Selecting previously deselected package gcc-4.1-base.
(Reading database ... 282346 files and directories currently installed.)
Unpacking gcc-4.1-base (from .../gcc-4.1-base_4.1.2-27ubuntu1_amd64.deb) ...
Selecting previously deselected package cpp-4.1.
Unpacking cpp-4.1 (from .../cpp-4.1_4.1.2-27ubuntu1_amd64.deb) ...
Selecting previously deselected package gcc-4.1.
Unpacking gcc-4.1 (from .../gcc-4.1_4.1.2-27ubuntu1_amd64.deb) ...
Processing triggers for man-db ...
Setting up gcc-4.1-base (4.1.2-27ubuntu1) ...

Setting up cpp-4.1 (4.1.2-27ubuntu1) ...
Setting up gcc-4.1 (4.1.2-27ubuntu1) ...



就可以在/usr/bin下看到嚕
ls /usr/bin/gcc*
/usr/bin/gcc  /usr/bin/gcc-4.1  /usr/bin/gcc-4.4  /usr/bin/gccbug-4.1



接下來需要做soft link

sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.1 /usr/bin/gcc

之後使用gcc -v
 就可以發現版本換嚕

gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --with-tune=generic --enable-checking=release x86_64-linux-gnu
Thread model: posix
gcc version 4.1.3 20080704 (prerelease) (Ubuntu 4.1.2-27ubuntu1)

透過Facebook分享

沒有留言: