Wednesday, October 12, 2016

VS Code + SFML

VS Code
https://code.visualstudio.com

c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": ["/usr/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        },
        {
            "name": "Linux",
            "includePath": ["/usr/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        },
        {
            "name": "Win32",
            "includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
            "C:/SFML-2.4.1/include",
            "C:/mingw32/include"
            ],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        }
    ]
}

tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "args": [
                "-g", "-o", "main.exe",
                "-std=c++11",
                "main.cpp",
                "-IC:/SFML-2.4.1/include",
                "-LC:/SFML-2.4.1/lib",
                "-lsfml-graphics-d",
                "-lsfml-window-d",
                "-lsfml-system-d"
            ],
    "showOutput": "always"
}

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/main.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "c:/mingw32/bin/gdb.exe"
            }
        },
        {
            "name": "C++ Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceRoot}/main.exe",
            "processId": "${command.pickProcess}",
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}


4 comments:

Unknown said...

Hey,

I can't seem to get this to work , can't even figure why.
Has there been any update that broke this ?

Thanks!

Unknown said...

No, it is still working great.
This is the only place I found on the internet, that really made it working for me.
Once you have all the files, change to your needs (adjust paths, so that your files are found), you can hit STRG+SHIFT+P in vs code and type "Run Build Task".
A big "Thank you" to the author for providing this.

P.S. Note, your main program file needs to be "main.cpp" with this standard configuration.

Unknown said...

Well, and you need to have the MS c/c++ extension installed..

Akash said...

can you give this setting for 2019 vscode setup