Follow the instructions here. Step 4 might give errors but it should still install. After this, running the following command should display gcc.
gcc --version
The following command should also work.
brew install gcc
In this case, the g++ command will still default to clang, but you can substitute g++-8 instead.
Open your bash profile with a text editor such as gedit.
brew install gedit
gedit ~/.bash_profile
Add the following functions.
co() {
g++ -std=c++17 -Ofast -Wall -Wl,-stack_size -Wl,0x10000000 -o $1 $1.cpp
}
run() {
co $1 && ./$1
}
Now you can easily run C++ from the command line by calling run.
run [prog name]
Make sure you have installed XCode command line tools.
xcode-select --install
xcode-select --version
softwareupdate --list
softwareupdate -i -a
For OS X Mojave, navigate to your bash profile
gedit ~/.bash_profile
and add the following line:
export CPLUS_INCLUDE_PATH="/usr/local/include/c++/8.1.0/:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include:$CPLUS_INCLUDE_PATH"
- Sublime Text 3
- Geany
- Visual Studio Code
- XCode
- mac
- Codeblocks
- bad on mac :(