Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

phl92

macrumors 6502
Original poster
Oct 28, 2020
301
47
I updated to Ventura and I wanted to write a C file in my IDE (Clion). I got a weird error code right away, that my gcc is not working.
I checked in the Mac terminal, and typing gcc tells me "error: no input files". I had to agree again in terminal the Xcode licence agreement, but I have the feeling that only clang is installed on my MacOS Ventura atm, and not gcc.
Is this normal?
How can I fix this?

I work on a Macbook Air M1
 
Normally the Xcode command line tools will install clang as your compiler and create a symlink so gcc will work as invoking clang. It has basically been like this since like Xcode 4 or something like that. A long time.
Clang and gcc are both good compilers and in a lot of cases you won’t need “real” gcc but you can easily get it with Brew
 
Normally the Xcode command line tools will install clang as your compiler and create a symlink so gcc will work as invoking clang. It has basically been like this since like Xcode 4 or something like that. A long time.
Clang and gcc are both good compilers and in a lot of cases you won’t need “real” gcc but you can easily get it with Brew
I am quite a newb with Mac and IDEs in general. Somehow CLion works now with clang. I dint really care which compiler is used, in case I would like to have both, because in my studies we use a lot of gcc
 
I am quite a newb with Mac and IDEs in general. Somehow CLion works now with clang. I dint really care which compiler is used, in case I would like to have both, because in my studies we use a lot of gcc
It was probably because of the EULA you needed to accept. You probably still don't have gcc. You can run gcc -v to check what version it is; It will say Apple Clang if it is the symlink situation

The way I have it set up, which is pretty much what installing gcc with brew will do by default, is that gcc is still symlinked to clang, but gcc-12 (version number) gives the Gnu Compiler Collection.

1669058483053.png


If you don't yet have homebrew I highly advise getting it. It's a very useful package manager. There's also other alternatives like Fink and MacPorts but homebrew has the most packages. With it, installing gcc is as simple as
"brew install gcc"

Also, for any future questions, if you use the developer forums specifically I have it set up so I get email alerts when there are new forum posts and can respond quickly - You can of course still get help in forums like the Ventura one here if people see it, but for questions like this the developer forum might give better results if you need future help in similar situations :)

Cheers
 
  • Like
Reactions: phl92
If you don't yet have homebrew I highly advise getting it. It's a very useful package manager. There's also other alternatives like Fink and MacPorts but homebrew has the most packages. With it, installing gcc is as simple as
"brew install gcc"
MacPorts (my overwhelming preference, but that's off-topic) has over 30,000 ports. I'd be very surprised if homebew exceeds that.
 
MacPorts (my overwhelming preference, but that's off-topic) has over 30,000 ports. I'd be very surprised if homebew exceeds that.
Past 30 days, GCC has been installed over 19,500 times through homebrew and only 160 times through MacPorts. homebrew is much more popular, with a much larger active user base, and therefore I assumed larger package count. I have seen lots of GitHub pages refer to homebrew in installation guides but only once seen MacPorts. Homebrew has GCC12, MacPorts' latest version is GCC11. So even if the count of different packages is higher with MacPorts it gets updated less frequently it seems. Homebrew has also verified its core tap against Ventura already, MacPorts does not have Ventura on their "port health" listing.

I like both, but I think that, especially for someone more new to the game, homebrew is a better choice.
Apple has used both though so I'd consider both solid choices.

But yeah, seems you're right that MacPorts has more packages, if the 30,000 figure is distinct packages. Homebrew has made it harder to get an exact count but last I checked it was in the region of 5k
 
My bad; I Retract that one. I looked over the list and only found 11; I overlooked 12 apparently and 11 was below it in the listing.
It appears however that you can only install specific version numbers with port? Does it not have a "port install gcc" that just always points to the latest release or what?

Do note that the numbers I previously gave for monthly installations were for GCC11 on Port, not 12. - 12 sees 233 monthly installs
 
It appears however that you can only install specific version numbers with port? Does it not have a "port install gcc" that just always points to the latest release or what?
You install one or more specific versions and then use port select to specify what gets invoked by gcc:
Code:
$ sudo port install gcc12
$ port select --list gcc
Available versions for gcc:
    mp-gcc12
    none
$ sudo port select --set gcc mp-gcc12
$ which gcc
/opt/local/bin/gcc
$ gcc --version
gcc (MacPorts gcc12 12.2.0_2+stdlib_flag) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It can sometimes be handy to have multiple gcc versions installed. BTW, installing a gcc version gets you more than just gcc:
Code:
$ port info gcc12
gcc12 @12.2.0_2 (lang)
Sub-ports:            libgcc12, gcc12-libcxx
Variants:             [+]stdlib_flag, universal

Description:          The GNU compiler collection, including front ends for C,
                      C++, Objective-C, Objective-C++ and Fortran.
Homepage:             https://gcc.gnu.org/

Extract Dependencies: xz
Build Dependencies:   texinfo
Library Dependencies: cctools, gmp, isl, ld64, libiconv, libmpc, mpfr, zlib,
                      zstd
Runtime Dependencies: gcc_select, libgcc, gcc12-libcxx
Platforms:            darwin
License:              (GPL-3+ or Permissive)
Maintainers:          none
 
You install one or more specific versions and then use port select to specify what gets invoked by gcc:
Code:
$ sudo port install gcc12
$ port select --list gcc
Available versions for gcc:
    mp-gcc12
    none
$ sudo port select --set gcc mp-gcc12
$ which gcc
/opt/local/bin/gcc
$ gcc --version
gcc (MacPorts gcc12 12.2.0_2+stdlib_flag) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It can sometimes be handy to have multiple gcc versions installed. BTW, installing a gcc version gets you more than just gcc:
Code:
$ port info gcc12
gcc12 @12.2.0_2 (lang)
Sub-ports:            libgcc12, gcc12-libcxx
Variants:             [+]stdlib_flag, universal

Description:          The GNU compiler collection, including front ends for C,
                      C++, Objective-C, Objective-C++ and Fortran.
Homepage:             https://gcc.gnu.org/

Extract Dependencies: xz
Build Dependencies:   texinfo
Library Dependencies: cctools, gmp, isl, ld64, libiconv, libmpc, mpfr, zlib,
                      zstd
Runtime Dependencies: gcc_select, libgcc, gcc12-libcxx
Platforms:            darwin
License:              (GPL-3+ or Permissive)
Maintainers:          none
That much is normal I think; You of course get dependencies when you install a package with dependencies. - Sounds like the update-alternatives way of doing things from a lot of Linux systems.

But IMO it's convenient to have a target that is just always the latest. With brew you can install either gcc-12 or gcc; gcc-12 installs version 12 explicitly (if already installed, marks it to be kept), where gcc installs the latest version (marked as updating, so when version 13 comes out, it will replace, unless gcc-12 was also installed in which case both will be kept).
Though the easy switch is nice
I considered switching to MacPorts at some point but I've just made too many tools for myself at this point that expect homebrew. zsh aliases, scripts I transport from computer to computer to install programs, libraries and fonts I want, etc.
The cask system for homebrew however is also rather nice.
For example Steam, Discord, Visual Studio Code, Adobe Creative Cloud - all installed with homebrew. Casks allow commercially licensed GUI apps to be managed the same way you manage all your other packages - That's a nicety of homebrew I think.

Alas we've hijacked the conversation a bit though I fear :p
 
Sorry for my late reply on this thread. Thanks a lot.
gcc -v
really only shows Clang as you guessed and now I will install homebrew and then gcc. If I have any issues with that, I will write here again, otherwise in the future in the dev forum as suggested by you.
Thank you!
 
  • Like
Reactions: casperes1996
Sorry for my late reply on this thread. Thanks a lot.
gcc -v
really only shows Clang as you guessed and now I will install homebrew and then gcc. If I have any issues with that, I will write here again, otherwise in the future in the dev forum as suggested by you.
Thank you!
No worries. Grumpus and I had a fun talk about preferences for package managers haha.
Best of luck to you!
 
  • Like
Reactions: phl92
I just installed Homebrew (took a while because he needed to install AGAIN Xcode command line??!) however I followed all instructions and then typed 'brew install gcc'. It was downloading and installing a lot but I actually never understand when he finished something doing. When I type now gcc -v' I still get the same Clang reply. Is this normal?
 
I just installed Homebrew (took a while because he needed to install AGAIN Xcode command line??!) however I followed all instructions and then typed 'brew install gcc'. It was downloading and installing a lot but I actually never understand when he finished something doing. When I type now gcc -v' I still get the same Clang reply. Is this normal?
Yes. The path for homebrew installed packages is lower priority than the default Apple PATH. To get the homebred-installed gcc, you need to write the specific version. As such
1669301047088.png


If you write "gcc-" and then hit the tab key (possibly twice) it will show you options or auto-fill the last bit
 
Awesome, I get the same reply now as you stated above when entering gcc-12 -v
Great help, thanks
 
  • Like
Reactions: casperes1996
Past 30 days, GCC has been installed over 19,500 times through homebrew and only 160 times through MacPorts. homebrew is much more popular, with a much larger active user base, and therefore I assumed larger package count. I have seen lots of GitHub pages refer to homebrew in installation guides but only once seen MacPorts. Homebrew has GCC12, MacPorts' latest version is GCC11. So even if the count of different packages is higher with MacPorts it gets updated less frequently it seems. Homebrew has also verified its core tap against Ventura already, MacPorts does not have Ventura on their "port health" listing.

I like both, but I think that, especially for someone more new to the game, homebrew is a better choice.
Apple has used both though so I'd consider both solid choices.

But yeah, seems you're right that MacPorts has more packages, if the 30,000 figure is distinct packages. Homebrew has made it harder to get an exact count but last I checked it was in the region of 5k
The differences between MacPorts and Homebrew are largely philosophical. MacPorts value stability, predictability and security higher while Homebrew value ease of use and lower disk usage higher. Homebrew will use whatever libs macOS already provides, while MacPorts will build the entire dependency tree. Homebrew will pull a pre-built binary while standard procedure in MacPorts is to pull the source and build. If you want to shave off every byte you can on a cramped disk, Homebrew will be more efficient. MacPorts require you to run install and other commands with side-effects as root (sudo), Homebrew simply changes ownership of the entire tree (and some things outside the tree) and lets you install and deinstall as a user. Easier, but less secure. If you want specific options set, then MacPorts is the best choice. MacPorts has mechanisms to have different builds and different versions of the same port installed. It is also possible (though a bit cumbersome) to pull and install old versions of ports. I can't see any of these two points being possible with Homebrew. MacPorts also supports older versions of macOS. Homebrew only supports current versions, nothing older.

I use MacPorts, but I almost always recommend people use Homebrew unless they have specific needs. (I also use Hemwbrew, but only to pull down casks.)

Since Homebrew is currently more popular, updates are fast. Neovim 0.8.0 was released at least a few weeks later through MacPorts than Homebrew.
 
  • Like
Reactions: casperes1996
The differences between MacPorts and Homebrew are largely philosophical. MacPorts value stability, predictability and security higher while Homebrew value ease of use and lower disk usage higher. Homebrew will use whatever libs macOS already provides, while MacPorts will build the entire dependency tree. Homebrew will pull a pre-built binary while standard procedure in MacPorts is to pull the source and build. If you want to shave off every byte you can on a cramped disk, Homebrew will be more efficient. MacPorts require you to run install and other commands with side-effects as root (sudo), Homebrew simply changes ownership of the entire tree (and some things outside the tree) and lets you install and deinstall as a user. Easier, but less secure. If you want specific options set, then MacPorts is the best choice. MacPorts has mechanisms to have different builds and different versions of the same port installed. It is also possible (though a bit cumbersome) to pull and install old versions of ports. I can't see any of these two points being possible with Homebrew. MacPorts also supports older versions of macOS. Homebrew only supports current versions, nothing older.

I use MacPorts, but I almost always recommend people use Homebrew unless they have specific needs. (I also use Hemwbrew, but only to pull down casks.)

Since Homebrew is currently more popular, updates are fast. Neovim 0.8.0 was released at least a few weeks later through MacPorts than Homebrew.
Agreed on all points. Sometimes older versions of packages can be gotten on Homebrew with @Version-number, but yeah, your points are good
 
Hey guys,
I have to update this thread, because I just wanted to update a software with homebrew and I noticed that my terminal on my Macbook is telling me that he cannot find brew. When I type 'which brew' I also get brew not found. How can it be that homebrew got deinstalled? I did not deactivate since last time,
 
Hey; Could you try to give us the output of echo $PATH? I don't think your home-brew is uninstalled if you haven't done anything. I think it's more likely your path just isn't set properly for the session. Is this an Apple Silicon or Intel Mac? Home-brew installs to different locations depending. If Apple Silicon did you install through a Rosetta Terminal or are you now running your Terminal through Rosetta?
 
Hi Casper,

I am having a M1 Macbook Air. I actually always just open my Terminal via Spotlight. What I have done indeed lately, is switching from bash to zsh Terminal quite some times. At the moment I am back at zsh.
echo $PATH you mean just what result I get with this command in the terminal?
 
Hi Casper,

I am having a M1 Macbook Air. I actually always just open my Terminal via Spotlight. What I have done indeed lately, is switching from bash to zsh Terminal quite some times. At the moment I am back at zsh.
echo $PATH you mean just what result I get with this command in the terminal?
Yes.

Changing between bash and zsh could potentially make a difference depending on how Homebrew's path is set, which I cannot remember at the moment and am away from my Mac for the Christmas time. On Intel, brew is installed to /usr/local/bin. IIRC it's installed to /opt/bin on M1, but it might be like /opt/local/bin or something like that
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.