Public Group

# Include SDL2 using Visual Studio Code, help :\

## Recommended Posts

Hi guys, long time no see, reason is I have put aside programming and focused on my japanese study, I'm still not done with it yet but from time to time I might try to code something just to not lose what I learn until I'm ready to further this as well again

So I was trying out Visual Studio Code (got tired of the starting time of Visual Studio 2017) and I'm trying to set up SDL2, but I'm getting the following error message when I build:

Quote

main.cpp:2:22: fatal error: SDL2/SDL.h: No such file or directory
#include "SDL2/SDL.h"

That has to be a lie, because I've already added the include path thus fixing the squiggly lines under  #include "SDL2/SDL.h" , and I'm also getting intellisense for SDL functions.

I've been strugling with this for several hours, and I cannot find a solution, so is time to ask for help

Below my task.json and c_cpp_properties.json , any idea of why I am getting this error and how to get it to build?

{
"version": "2.0.0",
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g","*.cpp", "-o", "Pacman", "-lSDL2", "-lSDL2main"
]
}
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher":"$gcc" } c_cpp_properties.json: { "configurations": [ { "name": "Mac", "includePath": [ "/usr/include", "/usr/local/include", "${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}" ], "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" }, "macFrameworkPath": [ "/System/Library/Frameworks", "/Library/Frameworks" ] }, { "name": "Linux", "includePath": [ "/usr/include", "/usr/local/include", "${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}" ], "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" } }, { "name": "Win32", "includePath": [ "Z:/Dependencies/SDL2-2.0.5/lib/x86", "Z:/Dependencies/SDL2-2.0.5/SLD2", "Z:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/include/*", "Z:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/atlmfc/include/*", "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um", "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt", "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared", "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt", "${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"Z:/Dependencies/SDL2-2.0.5/SLD2",
"Z:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/include/*",
"Z:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/atlmfc/include/*",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
"\${workspaceRoot}"
],
"databaseFilename": ""
}
}
],
"version": 3
}

Edited by MarcusAseth

##### Share on other sites

To further prove my include path aren't messed up, you can see the auto-complete when I type the include in the image below, so I cannot understand why when I build it tells me "No such file or directory"

Edited by MarcusAseth

##### Share on other sites

Solved

The solution was to add this 2 lines to the args of tasks.json

"-I Z:/Dependencies/SDL2-2.0.5/SLD2",
"-L Z:/Dependencies/SDL2-2.0.5/lib/x86", 

I guess the misunderstanding was in my assumption that the paths on the c_cpp_properties.json where for the compiler, those paths are probably only for intellisense purpose

1. 1
2. 2
frob
15
3. 3
Rutin
11
4. 4
5. 5

• 13
• 14
• 62
• 14
• 15
• ### Forum Statistics

• Total Topics
632128
• Total Posts
3004268

×