I continue to run into this include error / cannot open source file. I have now also tried resetting all of vs codes setting to default, but nothing I have tried has worked so far. Any advice on where to look would, or what's causing this would be extremely appreciated!
I have tried editing configurations in the json, adding to and editing the include paths and a few other long shot changes that I've come across on here.
I included a screen shot of the errors that I am currently encountering. I read somewhere that installing xcode fixed this issue for other people. But I don't use xcode, nor do I really want to.
My compiler is brew g++-11, I have also checked to make sure that the path in the json and the actual path match. I'm kind of at a loss what to do, I tried asking my professors today for help and they were just as lost. Any advice on where to look for a solution would be amazing.
I have also tried changing the include path from "${workspaceFolder}/**" to "${workspaceFolder}/inc". Which didn't work either.
Here is the current c_cpp_properties.json
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/usr/local/bin/gcc-11",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "macos-gcc-x64"
}
],
"version": 4
I also tried to check the intellisense extension settings, but that is admittedly a bit outside of my scope.
I fixed this after some settings are changed. Listed as below for your reference.
I don't know why. But it works.
BTW: my platform is Mac
当这发生在我身上时,我将编译器中的 bin 文件夹添加到系统环境变量中,此视频可能对您有所帮助
I had the same issue and here is how I solved it :
which XXX
where XXX
is your compiler and copy the pathIt should now work, however I never used c_cpp_properties.json file.
I had the same problem. Adding this to the include path fixed it: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
I got the path from running: gcc -v -E -x c++ -
Which outputs information about your gcc compiler. I'm on an M1 Mac running Monterey.
This is my vscode config:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
],
"defines": [],
"macFrameworkPath": [],
"compilerPath": "/opt/homebrew/bin/gcc-11",
"cStandard": "gnu17",
"cppStandard": "gnu++17"
}
],
"version": 4
}
As you see, the compiler is homebrew but the include path is xcode.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.