How to change the default GCC compiler in Ubuntu?

后端 未结 8 1401
孤街浪徒
孤街浪徒 2020-11-28 17:44

I have installed gcc-3.3/g++-3.3 on ubuntu 11.04 which already has gcc/g++-4.4. So in my system both gcc-3.3 and 4.4 are available. I am able to call both compilers as I wan

8条回答
  •  没有蜡笔的小新
    2020-11-28 18:48

    In case you want a quicker (but still very clean) way of achieving it for a personal purpose (for instance if you want to build a specific project having some strong requirements concerning the version of the compiler), just follow the following steps:

    • type echo $PATH and look for a personal directory having a very high priority (in my case, I have ~/.local/bin);
    • add the symbolic links in this directory:

    For instance:

    ln -s /usr/bin/gcc-WHATEVER ~/.local/bin/gcc
    ln -s /usr/bin/g++-WHATEVER ~/.local/bin/g++
    

    Of course, this will work for a single user (it isn't a system wide solution), but on the other hand I don't like to change too many things in my installation.

提交回复
热议问题