首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级到蒙特利后无法在Mac上使用gcc编写c++程序

升级到蒙特利后无法在Mac上使用gcc编写c++程序
EN

Stack Overflow用户
提问于 2022-01-11 02:30:47
回答 1查看 2.9K关注 0票数 2

*更新:对于类似的问题macos-wchar-h-file-not-found,命令行工具开关(xcode-select-install)不再存在。

我运行在macOS蒙特利系统上,我试图使用g++-11推荐(我用自制安装gcc )编译一个简单的hello .cpp文件,我得到了以下错误:

代码语言:javascript
复制
/usr/local/Cellar/gcc/11.2.0_3/include/c++/11/cwchar:44:10: fatal error: wchar.h: No such file or directory
   44 | #include <wchar.h>
      |          ^~~~~~~~~

我尝试了两个编译命令:

代码语言:javascript
复制
g++-11 -c hello.cpp -o hell.o 

g++-11 -std=c++11 -c hello.cpp -o hell.o

下面是我要编译的文件:

代码语言:javascript
复制
//
//  main.cpp
//  Test
//
//  Created by Jiali Zhu on 1/9/22.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-17 14:24:38

我也有同样的问题,在我的例子中,这个问题是过时的命令行开发工具。

我是从跑步中发现的

代码语言:javascript
复制
$ brew doctor
...
Warning: Your Command Line Tools are too outdated.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.1.

我试图通过softwareupdate -l更新它们,但是这并没有给我任何更新信息。

因此,删除了它们并重新安装了xcode-select --install

在这之后,g++-11停止给我一个关于这个标题的错误。

现在brew config告诉我我有CLT: 13.0.0.0.1.1627064638

附注:

另外,我启动了xcode,它问我是否需要安装其他组件,我说是的。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70660993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档