c++ - fatal error : string. h:没有那个文件或目录

标签 c++ xcode macos

在我的环境中,我无法包含 <cstring> . 我的 g++ 版本是 4.9.3 (Homebrew gcc49 4.9.3)。

错误是:

 - /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cstring:42:20: fatal
   error: string.h: No such file or directory
  "#include string.h"

但是,在另一个环境中(g++ 4.8.4[Ubuntu 4.8.4-2ubuntu1~14.04.3]),我可以包括<cstring>并运行。

问题是什么,我该如何解决?

[附言] 也许,我误解了这个问题。 我尝试运行我之前的代码,但出现了这样的错误:

    /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cassert:43:20: fatal error: assert.h: No such file or directory
 #include <assert.h>

然后,我无法运行我的代码。 这是一个g++的问题。

我检查了这篇文章,但这个程序不起作用。 我已经安装了 xcode-select(命令行工具),我卸载了 xcode-select 并重新安装了 xcode-select,但它不起作用。

Building C++ not working in OSX 10.9

最佳答案

重新安装 header 解决了我的问题:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

关于c++ - fatal error : string. h:没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39736728/

相关文章:

objective-c - cocoa 窗口最大垂直尺寸,但不是水平尺寸

c++ - 资源而不是外部文件 C++

c++ - 将模板类型名转换为 uint64

ios - 为什么在使用 swift 语言的 ios 中使用 CryptoSwift 框架时会出现此错误?

ios - 尝试将代码加载到我的 ios 设备时出现调试问题

macos - OS X上的Docker .net Core 3.0预览版3(Web API + Angle)

c++ - 错误 LNK2038 : mismatch detected for '_MSC_VER' : value '1600' doesn't match value '1700' in CppFile1. 对象

c++ - 列表框对齐问题

iphone - 无法从另一个 View 的 NSMutable 数组填充 UITableView

在 Google Drive 上的 R 项目中打开时,Rmarkdown 无法渲染内联绘图