'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:
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
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
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.
Solution 1:[1]
Apparently a macOS update had uninstalled the XCode developer tools.
I ended up uninstalling llvm
and libomp
, and when reinstalling it told me brew didn't have CLT
(use brew config
to check that).
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.
Solution 2:[2]
My solution:
- masOS12.3.1 monterey
"software update" --> "update commandLineTool" if push --> you can compile correctly without 'stdio.h' file not found.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tom |
Solution 2 | lihansey |