open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
I think that the problem is that for macOS Mojave users, the headers are no longer installed under /usr/include by default.
–
Adding on ssell's post and peter70's comment, I also still had issues after installing xcode command line tools again, and switching the xcode active developer directory. I was using CMake, and so deleted the debug/release folders which had existing Makefiles referencing out-of-date locations on Mojave. So for future problem resolving, after running the commands from ssell's post:
xcode-select --install
sudo xcode-select --switch /Library/Developer/CommandLineTools/
I believe if you've installed the command line tools by installing Xcode itself, you may also need to agree to the licence with sudo xcodebuild --license
. I don't think this is necessary if you used the prior xcode-select
command.
Then also delete generated build scripts. If using CMake, delete the cmake-build-debug
and cmake-build-release
directories (your names may vary)
Deleting all the generated files and restarted the compilation worked for me. It was suggested in this link:
https://discourse.brew.sh/t/solved-scan-build-from-llvm-7-0-seems-broken-on-macos-mojave/3151/14
–
–
–
xcode-select --install worked for me.
additionally if you're using visual studio code and your intellisense acts weird -
make a folder called .vscode
in your project root.
install vscode extension call C/C++ by microsoft
create the c_cpp_properties.json
file and paste the below contents
project_dir > .vscode > c_cpp_properties.json
"configurations": [
"name": "macOS",
"includePath": ["${workspaceFolder}/**"],
"defines": [],
"macFrameworkPath": ["/System/Library/Frameworks", "/Library/Frameworks"],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
"version": 4
If it happened after update Xcode you need (Apple WTF?) download and install Command Line Tools for Xcode manually from https://developer.apple.com/download/more/?=for%20Xcode
Or using terminal
xcode-select --install
Restart and maybe clean build cache (delete cmake-build-debug
) before run your project.
I guess it's needed every time after update Xcode for all major program update
The issue is that the path of compiler gets changed after update or other advancement maybe xcode reinstallment.
I have tried everything that was given on every site sadly none worked.
I figured out that many issues cause this .
But then what worked for me is unlinking gcc.
I had also installed gcc from homebrew earlier.
Just unlinking it worked for me.
So if you are also one of the few who has installed gcc from homebrew then
brew unlink gcc
should be sufficient to get it off your default path, so you'll be back to Xcode's default gcc (assuming you have that installed).
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.