I am in visual studio code. Trying to make this script work:
#include <SFML/Graphics.hpp>
int main()
{
sf::Window window(
sf::VideoMode(640, 480),
"Hello World");
return 0;
}
I am new to C++ and this concept of importing external libraries, so I am encountering problems.
I need the SFML library. I downloaded it, and I copied it in the following path: ${workspaceFolder}/libraries/SFML-2.6.1/include.
In include I have /SFML/Graphics.hpp, as I need.
So now I link my task.json file:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\MinGW\bin\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"-I ${workspaceFolder}/libraries/SFML-2.6.1/include", // Include path for SFML headers
"-L ${workspaceFolder}/libraries/SFML-2.6.1/lib", // Library path for SFML libraries
"${fileDirname}\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
and then my properties.json file:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/libraries/SFML-2.6.1/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/MinGW/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86"
}
],
"version": 4
}
When I run the script I get an error with the include, like it is not able to find Graphics.hpp.
What is wrong? Probably I need to better understand a few concepts of VisualStudio Code and how include works, but I am new to c++ coming from Python so please help me 🙂
Thanks!