1

I'm trying to install and include SFML into my VS Code and I am a absolute beginner as well. I looked up several videos on this topic but it wont help.

The code I am trying to run is a sample code from the SFML Website.

This is my task.json:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cpp.exe Aktive Datei kompilieren",
            "command":  "C:\\MinGW\\bin\\cpp.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "-O2",
                "-DNDEBUG",
                "-ggdb",
                "-pedantic-errors",
                "-Werror",
                "-Wall",
                "-Weffc++",
                "-Wextra",
                "-Wsign-conversion",
                "-std=c++20",
                "-Wconversion",
                "-IC:\\Users\\amirf\\Documents\\libraries\\SFML-2.5.1\\include\\SFML",
                "-LC:\\Users\\amirf\\Documents\\libraries\\SFML-2.5.1\\lib",
                "-lsfml-window",
                "-lsfml-graphics",
                "-lsfml-system",
                "-lsfml-audio", 
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",


            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Vom Debugger generierte Aufgabe."
        }
    ],
    "version": "2.0.0"
}

However if I try to include a sfml library, I always get: fatal error: SFML/Graphics.hpp: No such file or directory

I looked up other questions posted in stack overflow about that topic but all helpful answer where to include the paths in the task.json which I asume I already did

14
  • 2
    -I option is pretty dumb: compiler will take your include statement and first search directly for that file, then it will append the included file to each entry in -I option. You added include\SFML to your include path, so it will try to look for C:\\Users\\amirf\\Documents\\libraries\\SFML-2.5.1\\include\\SFML\\SFML/Graphics.hpp. Either #include "Graphics.hpp" directly or change your include path to ...\\SFML-2.5.1\\include Commented Mar 28, 2023 at 11:01
  • 2
    take off \\SFML at the end of the include path Commented Mar 28, 2023 at 11:04
  • 1
    took off \\SFML at the end of the include path and still the same error. I added SFML at the end of include path because it wasn't working right away. Commented Mar 28, 2023 at 11:06
  • 1
    @AmirKhan So the obvious question, where is Graphics.hpp on your system? Commented Mar 28, 2023 at 11:12
  • C:\Users\amirf\Documents\libraries\SFML-2.5.1\include\SFML here @john Commented Mar 28, 2023 at 11:13

1 Answer 1

1

I have already tried using VS Code for sfml but didn't manage to make it work. I recommend using visual studio 2019 (download link: https://visualstudio.microsoft.com/vs/older-downloads/) scroll down a bit and click on 2019 dropdown and download. When installed follow this tutorial: https://youtu.be/VWWSc2nqrEA.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.