Set up g++ on OS X

旧城冷巷雨未停 提交于 2019-12-30 10:38:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/19557614/set-up-g-on-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!