简体   繁体   English

macOS llvm 再也找不到 stdio.h

[英]macOS llvm can't find stdio.h anymore

I come to you with a weird problem I've been facing.我带着一个我一直面临的奇怪问题来找你。 So last week, I installed llvm and libomp for a C project, and it compiled just fine with this at the start of my makefile:所以上周,我为一个 C 项目安装了 llvm 和 libomp,它在我的 makefile 开始时编译得很好:

CC=clang
CFLAGS = -O2 -fopenmp
CFLAGS += -I/usr/local/opt/libomp/include
LDFLAGS = -fopenmp
LDFLAGS += -L /usr/local/opt/libomp/lib

Today I meant to finish that project, I opened vs code (I don't know if that's relevant), added some code left and right, and when I wanted to compile the code again to test if everything was fine, it gave me今天我打算完成那个项目,我打开了vs代码(我不知道那是否相关),左右添加了一些代码,当我想再次编译代码以测试是否一切正常时,它给了我

me@macbookPro% make
clang -c  -O2 -fopenmp -I/usr/local/opt/libomp/include bubble.c -o bubble.o
bubble.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make: *** [bubble.o] Error 1

which has left me dumbfounded since it worked just fine a few days ago.这让我目瞪口呆,因为它几天前工作得很好。 I tried to do an export CPATH with我试着做一个导出 CPATH

export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

but I got a bunch of warning and it didn't work either.但我收到了一堆警告,但也没有用。 Any help is greatly appreciated !任何帮助是极大的赞赏 !

Info: I'm running the latest version of BigSur and VSCode.信息:我正在运行最新版本的 BigSur 和 VSCode。

Apparently a macOS update had uninstalled the XCode developer tools.显然,macOS 更新已卸载 XCode 开发人员工具。

I ended up uninstalling llvm and libomp , and when reinstalling it told me brew didn't have CLT (use brew config to check that).我最终卸载了llvmlibomp ,并且在重新安装时告诉我 brew 没有CLT (使用brew config来检查)。

Then I ran the classic xcode-select --install then brew install llvm and brew install libomp , edited my path to include the llvm's bin and it works again.然后我运行经典的xcode-select --install然后brew install llvmbrew install libomp ,编辑我的路径以包含 llvm 的 bin 并且它再次工作。

My solution:我的解决方案:

  • masOS12.3.1 monterey masOS12.3.1 蒙特雷

"software update" --> "update commandLineTool" if push --> you can compile correctly without 'stdio.h' file not found. "software update" --> "update commandLineTool" if push --> 你可以在没有找到'stdio.h'文件的情况下正确编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM