2009-08-10

How to switch between diff gcc version?

You don't need to uninstall or reinstall anything in Debian. Take an example, you want to compile some code with gcc 4.3 und gcc 4.1 and compare the performance.

As root:
1) Install both of them
  • >apt-get install gcc 4.1
  • >apt-get install gcc 4.3
2) You could find both gcc exist at /usr/bin
  • >ls gcc*
3) Assume you want to set gcc 4.3 as default c compiler.
  • >cd /usr/bin
  • >ln -s gcc-4.3 gcc (create a symbolic link)
  • >export CC=/usr/bin/gcc (set variable)
  • Now you can complie you code now (e.g make)
4) If you want to use gcc 4.1, do the same thing as above.

In the most case, it works well.

No comments:

Post a Comment