OSX - replace gcc version 4.2.1 with 4.9 installed via Homebrew

后端 未结 4 1271
你的背包
你的背包 2020-11-28 20:00

This has been plaguing me for awhile now. I am trying to compile a huge C++ file (I know it works as I it works fine on my Arch Linux computer at work). When I checked my GC

4条回答
  •  温柔的废话
    2020-11-28 20:43

    simply updating the order of $PATH in ~/.bash_profile to the brew installed version 'export PATH=/usr/local/Cellar/gcc/5.1.0/bin:$PATH' was not enough to make the switch for me

    changing the alias in your ~./bash_profile (alias gcc='gcc-5') works, but can be confusing i.e. which gcc will return the Clang version

    what worked for me was to make a symbolic link in the brew gcc directory as well as update the path (point 1 above)

    cd /usr/local/Cellar/gcc/5.1.0/bin/gcc
    ln -s gcc-5 gcc
    

    now which gcc returns the correct version 5.1.0

提交回复
热议问题