How do i link the SFML libraries in Visual Studio Code?

Jason picture Jason · Jul 15, 2016 · Viewed 13.5k times · Source

I've been trying for hours and I can't seem to do it I've downloaded extensions and asked for help around but everything is just confusing me at this point. I want to include the SFML libs in my project and I'm trying to use the the Visual Studio Code editor for it but it just won't comply for some reason.

A picture of what it currently looks like. http://imgur.com/qJPlJua

I've been trying this for hours yesterday also but it just doesn't want to work.

Answer

Kaiden picture Kaiden · Nov 13, 2018

I know this question is about two years old, but after fiddling with my own tasks to solve this problem, and came up with something. This shouldn't be the best way to do it, but this should be good for anyone that finds this answer in the future.


{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile",
            "type": "shell",
            "group": "build",
            "command": "g++",
            "args": [
                "${file}",
                "-o",
                "${fileBasenameNoExtension}.exe",
                "-IC:\\SFML-2.5.1\\include",
                "-LC:\\SFML-2.5.1\\lib",
                "-lsfml-graphics",
                "-lsfml-window",
                "-lsfml-system",
            ],
            "problemMatcher": [
                "$gcc"
            ]
        }
    ],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared"
        //"showReuseMessage": true
    }
}

This should work the same as the above answer. Hit CTRL+SHIFT+B to bring up the Task prompt, or look up Run task in the Command Palette (CTRL+SHIFT+P). Remember to have the .dlls of each library used in the root of the project.

Hope this helps.