gpt4 book ai didi

c++ - 构建 C++ 在 OSX 10.9 中不起作用

转载 作者:IT老高 更新时间:2023-10-28 22:16:02 25 4
gpt4 key购买 nike

更新:

我最后通过重新安装命令行工具解决了这个问题,如图link .给您添麻烦了!

最初的问题

我刚刚升级到 OSX Mavericks,我不能再让编译器工作了。我一直在使用带有 vim/sb2 的 macports 的 gcc48,一切正常。现在,我包含的任何库都会产生大量错误。我不是很有经验,我不知道该做什么,或寻找什么。我只是希望它像以前一样工作。下面是编译一个基本的“hello world”程序时的内容:

In file included from /opt/local/include/gcc48/c++/bits/postypes.h:40:0,
from /opt/local/include/gcc48/c++/iosfwd:40,
from /opt/local/include/gcc48/c++/ios:38,
from /opt/local/include/gcc48/c++/ostream:38,
from /opt/local/include/gcc48/c++/iostream:39,
from ceva.cpp:1:
/opt/local/include/gcc48/c++/cwchar:44:19: fatal error: wchar.h: No such file or directory
#include <wchar.h>

如果您需要任何信息,请告诉我,我会提供给您。感谢您的耐心等待!

最佳答案

[Added 2019 - Mojave/Catalina] XCode 10 has removed the placement of headers in /usr/include, even with the command line tools. If you want headers, and you're on you should be able to install a transitional package, which is available on Mojave. This package is not present on the Catalina. The headers are within the SDK for the appropriate release.

XCode 5/Mavericks 更改了 header 所在位置的默认值。

在以前版本的 Mac OS X/XCode 上,您会在 /usr/include 中找到 header 。

当您在旧版本上构建 gcc 时,它会从该位置获取 header ,并在您尝试构建代码时现在在那里查找它们。

问题是文件不存在;它们位于 /Applications/Xcode.app/Contents/Developer 下。

您可以使用规范文件来使其再次一致地工作,但最明智的做法是重建 gcc。

如前所述,您可以使用 xcode-select --install 安装命令行工具,这将重新安装开发人员工具,包括 /usr/include 中的头文件.

当我升级操作系统时,我倾向于重新安装 gcc 之类的东西,因为我遇到了由于环境变化而导致的其他错误。这只是我养成的习惯。这可能不是最好的习惯,但它在很多情况下都让我免于痛苦。

[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.

关于c++ - 构建 C++ 在 OSX 10.9 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19575956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com