I am trying to set up SDL2 in vscode. This is how my project is structured and the main.cpp
The include folder in the src folder contains all the header files for SDL2, which includes SDL.h
Here is my c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/src/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
Now the problem:
main.cpp:1:10: fatal error: SDL.h: No such file or directory
#include <SDL.h>
^~~~~~~
compilation terminated.
I don’t get it, haven’t I already told it to look into src/include? In fact, it was vscode itself who wrote that line as a quick fix, but it still doesn’t work. And I don’t find a “configuration provider” messing up my project as many has encountered on the web. So why?
Does it have to do with setting.json? I did extensive search on the web but can’t find a definite answer, most posts just tells me to configure the c_cpp_properties and it should work.
Here is my setting.json
{
"files.associations": {
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"memory": "cpp",
"new": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp"
}
}
My eternal gratitude to anyone helping me solve this. If I miss any information please do tell. Really I was about to break something after spending so much time over this trivial task.
Tim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.