So I am a new programmer and I just installed XCode on my Macbook to get the GCC. I think Xcode is the only way for getting GCC on OSX. Now when I run my Hello World application, in C++, g++ comes up saying it is version 4.0.1 but when I look for commands starting with g I also see g++-4.2. Is there any way of making 4.2 default rather than 4.0.1, and also is there a way to updating gcc to the latest version 4.4.0?
EDIT: Ok, so I installed macports and installed gcc4.4 and it shows up on terminal as gcc-mp-4.4 and how do I make it default with gcc_select, like what are the commands and stuff. Thanks.
$ brew info gcc gcc: stable 11.2. 0 (bottled), HEAD GNU compiler collection https://gcc.gnu.org/ /usr/local/Cellar/gcc/11.2. 0_3 (2,163 files, 459.8MB) * ... Then using gcc-11 -v will get you actual version of gcc installed.
gcc is the C and C++ compiler developed by GNU project. It is widely adopted as the default compiler of UNIX-like systems. If you are using a Mac, you may also get gcc by installing Xcode (Developer) Tools in the Mac OS X installation Disc #1.
If you install macports you can install gcc select, and then choose your gcc version.
/opt/local/bin/port install gcc_select
To see your versions use
port select --list gcc
To select a version use
sudo port select --set gcc gcc40
I know it is an old request. But it might still be useful to some. With current versions of MacPorts, you can choose the default gcc version using the port command. To list the available versions of gcc, use:
$ sudo port select --list gcc
Available versions for gcc: gcc42 llvm-gcc42 mp-gcc46 none (active)
To set gcc to the MacPorts version:
$ sudo port select --set gcc mp-gcc46
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With