I can compile the code as follows:
#include <SFML/Graphics.hpp>
int main()
{
}
But I can't compile this:
#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;
}
C:\Users\Dolmatt\Desktop>g++ main.cpp -o main.exe -IC:\Utils\SFML-2.4.2\include
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x83): undefined
reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0xa7): undefined
reference to `__imp__ZN2sf9VideoModeC1Ejjj'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0xeb): undefined
reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15Co
ntextSettingsE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x127): undefined
reference to `__imp__ZN2sf11CircleShapeC1Efy'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x130): undefined
reference to `__imp__ZN2sf5Color5GreenE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x13e): undefined
reference to `__imp__ZN2sf5Shape12setFillColorERKNS_5ColorE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x151): undefined
reference to `__imp__ZNK2sf6Window6isOpenEv'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x170): undefined
reference to `__imp__ZN2sf6Window9pollEventERNS_5EventE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x18e): undefined
reference to `__imp__ZN2sf6Window5closeEv'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x1bc): undefined
reference to `__imp__ZN2sf5ColorC1Ehhhh'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x1da): undefined
reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x1e3): undefined
reference to `__imp__ZN2sf12RenderStates7DefaultE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x1ff): undefined
reference to `__imp__ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderState
sE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x212): undefined
reference to `__imp__ZN2sf6Window7displayEv'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x23b): undefined
reference to `__imp__ZN2sf12RenderWindowD1Ev'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x269): undefined
reference to `__imp__ZN2sf12RenderWindowD1Ev'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text+0x2af): undefined
reference to `__imp__ZN2sf12RenderWindowD1Ev'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text$_ZN2sf11CircleSha
peD1Ev[_ZN2sf11CircleShapeD1Ev]+0xf): undefined reference to `__imp__ZTVN2sf11Ci
rcleShapeE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text$_ZN2sf11CircleSha
peD1Ev[_ZN2sf11CircleShapeD1Ev]+0x21): undefined reference to `__imp__ZTVN2sf11C
ircleShapeE'
C:\Users\Dolmatt\AppData\Local\Temp\ccGgdEUQ.o:main.cpp:(.text$_ZN2sf11CircleSha
peD1Ev[_ZN2sf11CircleShapeD1Ev]+0x3b): undefined reference to `__imp__ZN2sf5Shap
eD2Ev'
collect2.exe: error: ld returned 1 exit status
How to solve the problem?