I am using vs code for c++ coding and i use sfml library for graphic programing . I draw a shape first and it very good but when I want use sfml library with the same code , vs code show me many errors like this :
' main.o:main.cpp:(.text+0xf0): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
Here is my code and it is a simple circle in a window and it worked before very fine .
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
this is my command to tell the compiler to find sfml headers in vs cod terminal :
g++ -c main.cpp -I/include
and this my command to tell the linker for finding sfmal libraries(.so files)
g++ main.o -o sfml-app -L/lib -lsfml-graphics -lsfml-window -lsfml-system this is my c_cpp_properties.json file
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\SFML-2.5.1\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "windows-gcc-x64",
"compilerPath": "C:\\MinGW\\bin\\g++.exe"
}
],
"version": 4
} and this is 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",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
} and this the errors messages :