Building C++ not working in OSX 10.9

落爺英雄遲暮 提交于 2019-11-28 20:38:07

XCode 5/Mavericks have changed the defaults for where headers are located.

On prior versions of Mac OS X / XCode you would have found headers in /usr/include.

When you built gcc on the older release it picked up the headers from that location, and looks for them there now when you try to build code.

The problem is that the files are not there; they're somewhere under /Applications/Xcode.app/Contents/Developer.

You could futz about with a spec file to get it working consistently again, but the sanest thing to do is rebuild gcc.

As has been mentioned as well, you can install the command line tools using xcode-select --install, which will reinstall the developer tools, including the headers in /usr/include.

I tend to reinstall things like gcc when I upgrade my operating system as I encounter other errors due to changes in the environment. This is just a habit I've formed. It may not be the best habit, but it's saved me pain on numerous occasions.

[added 2017] As an addendum, if you install the command line tools, then the headers will be placed in /usr/include as well. The command to install the command line tools is xcode-select --install - this will allow you to use most compilers without having to specify the location of the headers manually.

This is how I got it working on Mac osx Mavericks:

  1. Open terminal

  2. type --> xcode-select --install

  3. A pop-up windows will apear asking you about install tools

  4. choose install tools

  5. wait install to finish

uplearnedu.com

Here is a manual method for updating XCode on OS X Mavericks:

  1. Go into the developers site http://developer.apple.com

  2. Then go to Downloads for Apple developers and there is a command line tools installer for Mavericks — here's the link (but you'll need a developers account for the link to work) http://developer.apple.com/downloads/index.action?q=xcode

I'm using MacOs Sierra 10.12.4, got the same problem. I solved it by using:

/usr/bin/gcc

For me the fix was to uninstall old broken gcc:

brew uninstall gcc@5

I noticed paths like /usr/local/Cellar/gcc@5 in build output, while gcc@8 was also installed and is the one that was supposed to be used.

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