For VS Code I highly recommend to install the CMake extension and use the
SFML CMake Template.
That way you don't have to manually craft compile/build commands and it's guaranteed that SFML is built with the compiler you're using. Among other things like automatic debug/release switching.
For the given error, since you're using the
-g debug flag, you'll also need to link the SFML debug libraries, i.e. the ones with the
-d suffix.
And probably more importantly, your compiler has to match 100% the one used to build the SFML binaries. Best you download the compiler linked on the SFML download page.