Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Get SFML to work in VS code  (Read 10388 times)

0 Members and 1 Guest are viewing this topic.

Sogokong

  • Newbie
  • *
  • Posts: 3
    • View Profile
Get SFML to work in VS code
« on: December 11, 2018, 11:43:26 pm »
I have been trying to get SFML work in VS code for two days but no luck. I have tried different guides but non has proven helpful, so I decided to try it by my self.

Quick Info:
  • Windows 10 64x
  • minGW compiler
  • GCC 7.3.0 MinGW (DW2) - 32-bit
  • Visual Studio code v. 1.29.1

My c_cpp_properties.json:
Quote
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/SFML-2.5.1/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "path": [
                    "C:/SFML-2.5.1/include"
                ]
            }
        }
    ],
    "version": 4
}

My tasks.json:
Quote
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "type": "shell",
      "command": "g++",
      "args": [
        "-g",
        "main.cpp",
        "-lsfml-graphics",
        "-lsfml-window",
        "-lsfml-system"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "presentation": {
        // Reveal the output only if unrecognized errors occur.
        "reveal": "silent"
      },
      // Use the standard MS compiler pattern to detect errors, warnings and infos
      "problemMatcher": "$msCompile"
    }
  ]
}

I have tried to use the same commands a linux user is supposed to use in terminal, in my case powershell but got errors:

Quote
> gcc .\main.cpp -o test.exe -I"\SFML-2.5.1\include\" -lsfml-graphics -lsfml-window -lsfml-sy
stem
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system
collect2.exe: error: ld returned 1 exit status


Do someone know how I can make this work?
« Last Edit: December 11, 2018, 11:52:44 pm by Sogokong »

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Get SFML to work in VS code
« Reply #1 on: December 12, 2018, 02:04:24 am »
Missing -L maybe?
Back to C++ gamedev with SFML in May 2023

Sogokong

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Get SFML to work in VS code
« Reply #2 on: December 12, 2018, 09:01:03 am »
I have tried both -I and -L, both of them gave me today another error.

Quote
>gcc .\main.cpp -o test.exe -L"\SFML-2.5.1\include\" -lsfml-graphics -lsfml-window -lsfml-sy
.\main.cpp:1:29: fatal error: SFML/Graphics.hpp: No such file or directory
 #include <SFML/Graphics.hpp>

>gcc .\main.cpp -o test.exe -I"\SFML-2.5.1\include\" -lsfml-graphics -lsfml-window -lsfml-sy
.\main.cpp:1:29: fatal error: SFML/Graphics.hpp: No such file or directory
 #include <SFML/Graphics.hpp>

While replayin I so that I used gcc in cmd so I tried to use g++ but no differece.
« Last Edit: December 12, 2018, 09:04:15 am by Sogokong »

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Get SFML to work in VS code
« Reply #3 on: December 12, 2018, 10:13:09 am »
-I is for adding directories where your headers are.

-L is for adding directories where your libs (for you that'd be .a I think?) are.
Back to C++ gamedev with SFML in May 2023

Sogokong

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Get SFML to work in VS code
« Reply #4 on: December 12, 2018, 02:41:00 pm »
So I have to use both? Could you be more specific with how I'm supposed to build in win10?

rockmetal26

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Get SFML to work in VS code
« Reply #5 on: August 15, 2020, 05:04:52 am »
Hello, in this video I explain how to do the process



 

anything