не получается подключить и запустить статический sfml
Есть такой простой код:
#include "SFML/Graphics.hpp"
int main(void) {
sf::RenderWindow window(sf::VideoMode(800, 800), "SFML Window.");
sf::RectangleShape rectangle(sf::Vector2f(20, 20));
rectangle.setPosition(10, 10);
rectangle.setRotation(40);
while(window.isOpen()) {
sf::Event event;
while(window.pollEvent(event)) {
if(event.type == sf::Event::Closed) {
window.close();
}
}
window.clear(sf::Color::Black);
window.draw(rectangle);
window.display();
}
return 0;
}
Скомпилировал исходники SFML через CMake.
В SFML\lib\ есть все библиотеки, а в SFML\include\ все include файлы, и в SFML\bin\ есть openal32.dll
Пытаюсь запустить программу так: g++ test.cpp -o test.exe -std=c++11 -Wall -DSFML-STATIC -I SFML\include\ -L SFML\lib -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32 -lfreetype
Вывод:
<command-line>: warning: ISO C++11 requires whitespace after the macro name
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x83): undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0xa7): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0xeb): undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x13f): undefined reference to `__imp__ZN2sf14RectangleShapeC1ERKNS_7Vector2IfEE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x163): undefined reference to `__imp__ZN2sf13Transformable11setPositionEff'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x17f): undefined reference to `__imp__ZN2sf13Transformable11setRotationEf'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x19e): undefined reference to `__imp__ZN2sf6Window5closeEv'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x1b5): undefined reference to `__imp__ZN2sf10WindowBase9pollEventERNS_5EventE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x1c2): undefined reference to `__imp__ZN2sf5Color5BlackE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x1d7): undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x1e0): undefined reference to `__imp__ZN2sf12RenderStates7DefaultE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x1f9): undefined reference to `__imp__ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x20c): undefined reference to `__imp__ZN2sf6Window7displayEv'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x21f): undefined reference to `__imp__ZNK2sf10WindowBase6isOpenEv'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x24b): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text+0x2a7): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text$_ZN2sf14RectangleShapeD1Ev[_ZN2sf14RectangleShapeD1Ev]+0xf): undefined reference to `__imp__ZTVN2sf14RectangleShapeE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text$_ZN2sf14RectangleShapeD1Ev[_ZN2sf14RectangleShapeD1Ev]+0x21): undefined reference to `__imp__ZTVN2sf14RectangleShapeE'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\IonE\AppData\Local\Temp\ccMBe0qT.o:test.cpp:(.text$_ZN2sf14RectangleShapeD1Ev[_ZN2sf14RectangleShapeD1Ev]+0x3b): undefined reference to `__imp__ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
Как пофиксить?
Источник: Stack Overflow на русском