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
$ 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

Edit 2

$ cat > /tmp/foo.c << EOFeof

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

gcc /tmp/foo.c -o /tmp/foo
gcc: error trying to exec 'cc1': execvp: No such file or directory
zsh: no such file or directory: /tmp/foo
  • What is the reason to use gcc and not clang? – Mark Mar 18 at 16:09
  • Several reasons. GCC has features that clang does not, GCC is often first to adopt new standards and language features. GCC is what many others use and it is useful to have the same compiler as my peers. I like clang and usually use it, but sometimes it is necessary to use GCC. – zoecarver Mar 18 at 16:15
  • I added an edit to my answer. Have you removed bcc from brew and validated the core system builds? Once you’re sure that compiler works, when you reinstall gcc - run brew doctor before and after the brew install and watch for errors installing gcc itself. I know you said you uninstalled, but this seems like something outside the gcc to me hence my expansive answer to try clang as well. Hopefully someone has a better answer. Maybe @Mark? – bmike Mar 18 at 22:13

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

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

gcc /tmp/foo.c -o /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
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.

  • thanks for the response! I have updated my question accordingly. – zoecarver Mar 11 at 17:06
  • You deleted foo in /tmp/foo && rm /tmp/foo before running file /tmp/foo, so that's interesting. – user3439894 Mar 11 at 17:24
  • What do you mean? – zoecarver Mar 11 at 20:44
  • @user3439894 In bash the "rm" runs only when /tmp/foo returns 0 - no error condition. You're correct that I did skip the rm to show that it was made successfully, so perhaps it would be better to edit. Thanks for the suggestion! – bmike Mar 11 at 22:11
  • @bmike, I'm well aware of && and the reason for its usage; however, on your system I'm pretty sure /tmp/foo exited with 0 and I found it a bit interesting that file /tmp/foo didn't return /tmp/foo: cannot open '/tmp/foo' (No such file or directory) as I would expect it to on a a working system the way you laid out the commands. Also, to the comment you made for the edit, if your were worried about /tmp being left dirty why not use /tmpfoo && rm foo foo.c instead, after all both files would be created on a working system. – user3439894 Mar 12 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .