You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS下升级CLion版本后标准C++头文件缺失问题

CLion升级后找不到C++标准头文件的解决方法

注意: 此问题并非“macOS升级至Catalina后CLion无法找到C++头文件”的重复问题


问题描述

CLion提示我唯一的C++项目中所有头文件均缺失:

#include <cstdio>
^^^^^^^^^^^^^^^^^^

'cstdio' file not found

此前一切正常,自通过JetBrains ToolBox将CLion从v2024.1.5升级至v2024.2.2后,问题开始出现。

更新

在我的Mac上安装XCode更新时也出现了同样的问题(下文给出的解决方法同样有效)


已尝试的操作

  • Build > Rebuild Project
  • Tools > CMake > Reload CMake Project
  • CLion > Settings > Build, Execution, Deployment > CMake > Manage toolchains... > OK

环境信息

  • CLion 2024.2.2 Build #CL-242.22855.75
  • macOS Sonoma 14.6.1,Apple M1 Pro芯片,内存32 GB

解决步骤

1. 重置并重新安装XCode Command Line Tools

打开终端执行:

sudo xcode-select --reset
xcode-select --install

按照提示完成安装,期间可能需要输入系统密码。

2. 验证并修复CLion工具链配置

  1. 打开CLion > Settings > Build, Execution, Deployment > Toolchains
  2. 确认当前使用的Apple Clang工具链路径正确(默认应为/Library/Developer/CommandLineTools)
  3. 若工具链状态异常,点击+按钮重新添加Apple Clang,让CLion自动检测配置后保存

3. 清除CLion缓存并重启

  1. 点击File > Invalidate Caches...
  2. 勾选Clear file system cache and local history选项
  3. 点击Invalidate and Restart,等待CLion重启并重新索引项目

4. 手动指定CMake编译器路径(可选)

若上述步骤无效,在CLion > Settings > Build, Execution, Deployment > CMake的CMake options中添加:

-DCMAKE_C_COMPILER=/usr/bin/clang
-DCMAKE_CXX_COMPILER=/usr/bin/clang++

添加完成后,执行Tools > CMake > Reload CMake Project。


内容的提问来源于stack exchange,提问作者y2k-shubham

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 05:42:47