0

I am attempting to use SFML for my next project, however I have yet to find reliable information on how to install SFML for MinGW, the page on the main SFML website is for using code::blocks, and I would prefer to keep using VS Code if I could. Additionally all of the tutorials for visual studio are for older versions where the UI is much different. I was hoping that someone who has installed it could guide me through the steps they used to install it. Thanks.

I am on Windows.

2 Answers 2

0

Just to be clear, I have never used Visual Studio Code, but it supports Nuget Package Manager, so it should work the same as in the 'normal' Visual Studio. So after creating new project:

  • Your should be getting/installing Nuget Package Manager from here.
  • Then according to answers to this question, you should be able to Press Ctrl+P or Ctrl+Shift+P and search for SFML packages, and choose version 2.5.1.
  • There are five modules: Audio, Graphics, Network, System and Window, choose what you need or install all five.

As I said at the begining, I do not have a way to test it, but it should work.

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

3 Comments

Wouldn’t that just allow VS to access the libraries? Whether or not VS marks it as correct or not is less important than my compiler being able to read the libraries.
In standard VS it adds those modules to your project folder. You can then include them as you wish. This is what I understand by "install SFML for the project"
I tried using NuGet to install the packages and was greeted by this error: Cannot find any .csproj or .fsproj file for your project! Please fix this error and try again.
0

This question is fairly old at this point but for anyone in the future wondering how I solved it, I ended up switching compilers to Clang and creating a .bat file the just runs clang++ and links the SFML lib directory. (SFML GCC-64 worked fine with Clang)

To fix any errors in VS Code, you can add SFML to the workspace config

in .vscode/c_cpp_properties.json: add or edit a field called "configurations" (should be an array), and add the following:

    "configurations": [
      {
        "name": "SFML",
        "intelliSenseMode": "clang-x64",
        "includePath": ["${defaultInclude}", "C:/libs/SFML/GCC-64-Bit/SFML-2.5.1/include"],
        "compilerPath": "C:/msys64/mingw64/bin/clang++.exe",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "browse": {
          "path": ["${workspaceFolder}"],
          "limitSymbolsToIncludedHeaders": true,
          "databaseFilename": ""
        }
      }
    ]

You'll have to change some of the paths to fit your setup, and you could very well put this in your global C++ configuration.

Finally, make sure that the needed DLLs are copied to your compilation output directory

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.