MacOS – cc1plus: no such file or directory (gcc)

gccmacos

Issue

Every time I try to compile something with gcc I get this error:

gcc: error trying to exec 'cc1plus': execvp: No such file or directory

What I tried

I have tried uninstalling gcc and re-installing it using brew.

Other Info

I am on a MBP 2015 running Mojave.

Edit 1

$ file $(which gcc)
/usr/local/bin/gcc: Mach-O 64-bit executable x86_64                                 
$ which gcc
/usr/local/bin/gcc
$ gcc --version
gcc (Homebrew GCC 8.2.0) 8.2.0
Copyright (C) 2018 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.

Edit 2

$ cat > /tmp/foo.c << EOFeof
#include<stdio.h>

int main(void) {
    printf("Hello World\n");
    return 0;
}
EOFeof

gcc /tmp/foo.c -o /tmp/foo
/tmp/foo
gcc: error trying to exec 'cc1': execvp: No such file or directory
zsh: no such file or directory: /tmp/foo

Best Answer

Something is going to be messed up, but with the details given I don't even know where to guess what you have wrong. Instead. let's go the other way and try something super minimal that should show your failure immediately.

Here's a simple end to end test of gcc that ships from Apple should work. I'm using the version that ships with Mojave (ProductVersion: 10.14.3 BuildVersion: 18D109) according to the sw_vers command on macOS.

cat > /tmp/foo.c << EOFeof
#include<stdio.h>

int main(void) {
    printf("Hello World\n");
    return 0;
}
EOFeof

gcc /tmp/foo.c -o /tmp/foo
/tmp/foo

Where I'd start is which actual GCC and version you're running:

Mac:~ me$ file /tmp/foo
/tmp/foo: Mach-O 64-bit executable x86_64
Mac:~ me$ file $(which gcc)
/usr/bin/gcc: Mach-O 64-bit executable x86_64
Mac:~ me$ which gcc
/usr/bin/gcc
Mac:~ me$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Then you can repeat the test in your flavor of gcc to suss out the differences or if you even need the bcc that’s not the clang implementation of a gcc like compiler.

What specific error or what specific differences do you have? Feel free to start a new thread or edit / refine your question and then @ me in the comments.