I will learn SFML for C++. I want to install SFML in Vscode but after this code
mingw32-make -f Makefile
I get this error:
g++ -Isrc/include -c coding/*.cpp
g++ *.o -o main -Lsrc/lib -lsfml-graphics -lsfml-window -lsfml-system
main.o:main.cpp:(.text+0x7c): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
main.o:main.cpp:(.text+0xa2): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
main.o:main.cpp:(.text+0xde): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
main.o:main.cpp:(.text+0x115): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
main.o:main.cpp:(.text+0x126): undefined reference to `_imp___ZN2sf5Color5GreenE'
main.o:main.cpp:(.text+0x130): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
main.o:main.cpp:(.text+0x142): undefined reference to `_imp___ZNK2sf10WindowBase6isOpenEv'
main.o:main.cpp:(.text+0x162): undefined reference to `_imp___ZN2sf10WindowBase9pollEventERNS_5EventE'
main.o:main.cpp:(.text+0x182): undefined reference to `_imp___ZN2sf6Window5closeEv'
main.o:main.cpp:(.text+0x1af): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
main.o:main.cpp:(.text+0x1ca): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
main.o:main.cpp:(.text+0x1dd): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
main.o:main.cpp:(.text+0x1f1): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
main.o:main.cpp:(.text+0x203): undefined reference to `_imp___ZN2sf6Window7displayEv'
main.o:main.cpp:(.text+0x229): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
main.o:main.cpp:(.text+0x273): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0xa): undefined reference to `_imp___ZTVN2sf11CircleShapeE'
main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x17): undefined reference to `_imp___ZTVN2sf11CircleShapeE'
main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x2a): undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
Makefile:7: recipe for target 'link' failed
mingw32-make: *** [link] Error 1
What is the solution to this error?
main.cpp :
#include <SFML/Graphics.hpp>
using namespace std;
using namespace sf;
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;
}
Makefile :
all: compile link
compile:
g++ -Isrc/include -c coding/*.cpp
link:
g++ *.o -o main -Lsrc/lib -lsfml-graphics -lsfml-window -lsfml-system
I have taken care of my minGW installations and all other details, but when I proceeded through the steps, I encountered this problem.I also made my path settings in my json file as follows: ” “C_Cpp.default.includePath”: [“${workspaceFolder}/**”] ” Please help.
Görkem Hazar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.