I am trying to write c++ using vscode on Mac, but I kept receiving this error when trying to run any code.
The code I want to run:
#include <iostream>int main() { std::cout << "Hello World!"; return 0;}
The error I got:
[Running] cd "/Users/joanne/Desktop/C++/"&& g++ Hello.cpp -o Hello && "/Users/joanne/Desktop/C++/"HelloIn file included from /Users/joanne/anaconda3/gcc/include/c++/cwchar:44:0, from /Users/joanne/anaconda3/gcc/include/c++/bits/postypes.h:40, from /Users/joanne/anaconda3/gcc/include/c++/iosfwd:40, from /Users/joanne/anaconda3/gcc/include/c++/ios:38, from /Users/joanne/anaconda3/gcc/include/c++/ostream:38, from Hello.cpp:1:/Users/joanne/anaconda3/gcc/include/c++/wchar.h:29:24: fatal error: wchar.h: No such file or directory #include_next "wchar.h" ^compilation terminated.[Done] exited with code=1 in 0.096 seconds
Some information:
macOS Catalina 10.15.2
Xcode 10.4.1
$ clang --versionclang version 4.0.1 (tags/RELEASE_401/final)Target: x86_64-apple-darwin19.2.0Thread model: posixInstalledDir: /Users/joanne/anaconda3/bin
$ gcc --versiongcc (GCC) 4.8.5Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which gcc/Users/joanne/anaconda3/bin/gcc
$ /usr/bin/gcc --versionConfigured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1Apple clang version 11.0.3 (clang-1103.0.32.59)Target: x86_64-apple-darwin19.2.0Thread model: posixInstalledDir: /Library/Developer/CommandLineTools/usr/bin
I have also installed /usr/local/Cellar/gcc/9.3.0_1/bin
with homebrew.
My includepath setting:
{"configurations": [ {"name": "Mac","includePath": ["${workspaceFolder}/**","/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++","/usr/local/Cellar/gcc/9.3.0_1/include/","/Library/Developer/CommandLineTools/usr/include/c++","/Users/joanne/anaconda3/gcc/include/c++","/Library/Developer/CommandLineTools/usr/include/c++/v1","/usr/local/Cellar/gcc/9.3.0_1/include/c++/9.3.0/x86_64-apple-darwin19","/Users/joanne/anaconda3/gcc/include/c++/x86_64-apple-darwin11.4.2" ],"defines": [],"macFrameworkPath": ["/System/Library/Frameworks","/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/Library/Apple/System/Library/Frameworks","/Library/Frameworks" ],"compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "clang-x64" } ],"version": 4}
I tried open macOS_SDK_headers_for_macOS_10.14.pkg
But it doesn’t work cause there’s no file named macOS_SDK_headers_for_macOS_10.14.pkg
in macOS Catalina anymore I guess?
Anyone know how to fix this?