Skip to main content
  1. Posts/

How to fix "error trying to exec f951: execvp: No such file or directory"

·334 words·2 mins
error trying to exec 'f951': execvp: No such file or directory  
error trying to exec 'cc1': execvp: No such file or directory  

I was trying to compile a program today on OS X Lion using gfortran, but to my disappointment I got these errors every time. I am not really familiar with this kind of stuff, so I wasn’t sure where to look at first. Even when trying to compile a simple hello_world program.

The internet wasn’t very useful either. Google gave me barely anything :-(

The solution #

First I removed xcode, with the idea to reinstall it later:

sudo /Developer/Library/uninstall-devtools -mode=all

After that I dug into my /usr/local/lib and /usr/bin folders and removed any reference to gcc, gcov, g++, cpp and gfortran, which are all part of the gcc package.

I also removed all references to llvm-* (where * can be gcc, g++, etc). This comes with xcode, not really sure what this is used for. And finally I removed the libgcc/ folder and all libgfortran-related files in /usr/local/lib.

I rebooted for good measure.

Next I got Xcode 4 from the Appstore (for OS X 10.6 and lower, it’s available on the Mac Dev Center and installed it. Again I went into my /usr/bin/ and removed the symlink xcode made to their (incomplete, it misses gfortran) gcc.

I downloaded and installed gcc-lion.tar.gz from HPC and installed using:

gunzip gcc-lion.tar.gz
sudo tar -xvf gcc-bin.tar -C /

After that, everything seemed to work! There is without doubt a faster way to fix it, but after trying to fix it for a few hours, I’m glad it now works! :-)

What else? #

If gcc gives an error that looks something like this:

ld: symbol(s) not found for architecture x86_64 
collect2: ld returned 1 exit status,  

an explanation can be found here. Basically, the lstdc++ parameter has to be given, so it uses the correct library. Alternativey, g++ or clang++ can be used directly.

Original post on