Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In trying to get g++ to work in terminal I ran a command which I have now learned is outdated.

I think this is why running g++ in terminal returns an error but I am unsure.

If I try to run any .cpp in terminal I get the error message:

xcrun: Error: failed to exec real xcrun. (No such file or directory)

I have xcode installed and have installed command line tools. However after doing so, I ran the command below:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/

What have I done, and what should I do?

share|improve this question
Wait, you're trying to run a .cpp (C++ source code) file, as opposed to compile it? What happens if you just do g++ -o program program.cpp ? – derobert Nov 19 '13 at 16:15
What command did you type that gave the xcrun error? – Warren Young Nov 19 '13 at 16:19

I believe you have simply pointed xcode-select at the wrong part of the Xcode directory structure. You should be able to undo this with:

xcode-select -reset

In the future, if you need it, The xcode-select tool can find what it needs by being given just the path to the Xcode app you want to use:

xcode-select --switch /Applications/Xcode.app
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.