Created
March 4, 2018 22:11
-
-
Save lnrsoft/19aca8291f11fe11126e2942c5f065e0 to your computer and use it in GitHub Desktop.
This script will set the latest g++-7.3.0, gcc-7.3.0, c++-7.3.0 and cc-7.3.0 as the system default gcc compiler on OSX.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set g++-7.3.0, gcc-7.3.0, c++-7.3.0 and cc-7.3.0 as the default gcc compiler on OSX | |
# Method: removing the old versions and replacing them with symbolic links of the latest build. | |
# gcc-7.3.0 | |
# Note: we do not need to remove the previous version of cc, c++, gcc, g++. | |
# We can also rename them as we might need them again. I decided them in this script. | |
# run as root | |
# Roland Ihasz - March, 2018 | |
set -e | |
cd /usr/bin/ | |
sudo rm -rf /cc | |
sudo rm -rf /gcc | |
sudo rm -rf /c++ | |
sudo rm -rf /g++ | |
sudo ln -s /usr/local/bin/gcc-7.3.0 /cc | |
sudo ln -s /usr/local/bin/gcc-7.3.0 /gcc | |
sudo ln -s /usr/local/bin/c++-7.3.0 /c++ | |
sudo ln -s /usr/local/bin/g++-7.3.0 /g++ | |
echo -e "Symbolic links have been sucessfully created." | |
echo -e "The default gcc version is: " | |
sudo -u root /usr/bin/g++ -v | |
echo "PATH=\"/usr/local/bin:$PATH\"" >> ~/.bash_profile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set -e
cd /usr/bin/
sudo rm -rf /cc
sudo rm -rf /gcc
sudo rm -rf /c++
sudo rm -rf /g++
sudo ln -s /usr/local/bin/gcc-8.1.0 /usr/local/bin/cc
sudo ln -s /usr/local/bin/gcc-8.1.0 /usr/local/bin/gcc
sudo ln -s /usr/local/bin/c++-8.1.0 /usr/local/bin/c++
sudo ln -s /usr/local/bin/g++-8.1.0 /usr/local/bin/g++
echo -e "Symbolic links have been sucessfully created."
echo -e "The default gcc version is: "
sudo -u root /usr/bin/g++ -v
echo "PATH="/usr/local/bin:$PATH"" >> ~/.bash_profile