3

I just updated to OS X Mavericks and it seems it messed up my whole compiler setup. Not only do I have to reinstall a JDK in order to use a Java compiler, I get the following error when I'm trying to compile C/C++ using GCC/G++:

/usr/local/Cellar/gcc/4.7.2/gcc/lib/gcc/x86_64-apple-darwin12.2.1/4.7.2/../../../../include/c++/4.7.2/cwchar:46:19: fatal error: wchar.h: No such file or directory

Not sure what to think other than upgrading messed it up. My question is: how do I set up g++ to compile on OS X? If it's already set up, what is the problem here?

If I can provide more information, please let me know.

Note: I've installed gcc 4.7 using homebrew, but it doesn't seem to work. When I use g++-4.7 code.cpp specifically, I get the same error.

2
  • afaik osx gets set up when xcode gets installed with the command line tools
    – Zaiborg
    Oct 24, 2013 at 5:39
  • Originally, yes. I tried to set it up on the latest version back on ML and had it working. I can't remember how I got it set up, though, and I feel like there shouldn't have been a major change to that in upgrading...
    – muttley91
    Oct 24, 2013 at 5:44

1 Answer 1

5

Installing the Command Line Tools (OS X Mavericks) for Xcode - Late October 2013 solved it for me. Here is the link:

OSX: Xcode Downloads

The often mentioned xcode-select --install command kept saying it cannot find the requested software.

To clarify: You need to already have gcc-4.7 installed using Homebrew. The update to the latest version of CMD Tools only fixes compatibility issues caused by upgrading from Mountain Lion to Mavericks.

4
  • Do you know if this will allow for C++11 support? I have the Command Line Tools installed, but I think I did this early this year or possibly late last year.
    – muttley91
    Oct 25, 2013 at 15:21
  • Using g++-4.7 --std=c++11 gives C++11 support. I have been using the Mac OS 10.8 Command Line Tools while using Mountain Lion (most likely the one you have downloaded). Upon upgrading to Mavericks I received your aforementioned error msg and installed the appropriate Command Line Tools for Mavericks. From then on all has been running smoothly.
    – Marius
    Oct 25, 2013 at 22:47
  • I'm confused; you say you solved it by installing the Xcode command line tools and yet you aren't using them if you are using g++-4.7. When you have Xcode 5 command line tools installed then g++ is an alias for clang++ as there is no GCC support in Xcode 5.
    – trojanfoe
    Oct 31, 2013 at 16:40
  • Apologies, I should have clarified: This 'fix' is based on a gcc-4.7 installation using Homebrew.
    – Marius
    Nov 1, 2013 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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