Macos – Installing GCC on macOS Catalina

gccmacos

I am on macOS Catalina and trying to install GCC by following the instructions here:
https://solarianprogrammer.com/2019/10/12/compiling-gcc-macos/

Everything seems to work fine until I try to configure. Then I get the following:

configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

While trying to fix this I found the following:

MacOS "configure: error: cannot run C compiled programs"

However this answer requires going to the following directory:

/Library/Developer/CommandLineTools

The problem is I do not have CommandLineTools in /Library/Developer/ not even as a hidden file. Trying to fix this I found this

How to compile GCC on macOS Catalina?

but there is now answer here and I do not have nix and don't want to mess with it as it appears to not be very compatible with macOS Catalina. So the question is how can I run the configure?

Best Answer

First you need to install the Command-Line tools.

$ xcode-select --install

Then you probably want to install the headers from a specific .pkg in Terminal:

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

(yours is 10.15, so):

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.15.pkg

After finishing the installation you should have the headers you need to compile with your GCC.