Skip to content

Instantly share code, notes, and snippets.

@lnrsoft
Created March 4, 2018 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lnrsoft/19aca8291f11fe11126e2942c5f065e0 to your computer and use it in GitHub Desktop.
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.
#!/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
@lnrsoft
Copy link
Author

lnrsoft commented Jul 8, 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-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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment