Reputation: 125
When attempting to setup SDL2 with VS Code in Ubuntu 20.01 LTM I get the following VS Code error:
cannot open source file "begin_code.h" (dependency of "SDL2/SDL.h")
Any tips?
Upvotes: 3
Views: 7745
Reputation: 179
in case you don't have the "c_cpp_properties.json" file in your folder.
Different answer than above, but I believe might be a better approach.
to create the c_cpp_properties.json on your workspace do the following:
I'm assuming you already have the extension "C/C++ IntelliSense, debugging, and code browsing" installed on your vscode.
After these steps this problem was fixed for me.
Upvotes: 1
Reputation: 1221
If you, like me, don't have the c_cpp_properties.json
file in your project, you can solve it by adding the following line to your settings.json
(in VSCode, hit Ctrl+Shift+P and search for Open settings (JSON)):
{
// ...
"C_Cpp.default.includePath": ["/usr/include/SDL2", "${default}"],
//...
}
Upvotes: 0
Reputation: 125
Just add "/usr/include/SDL2/"
to your c_cpp_properties.json like so:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/SDL2/"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu18",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Upvotes: 4