Salut à tous
Voilà, je suis bloqué depuis quelque temps sur un problème alors que je souhaite compiler avec un makefile un petit bout de code pris sur le net avec la bibliothèque SFML 2.3.2
Je précise que cela compilait et marchait sur Linux (avec un makefile équivalent, et si je n'ai pas glissé une erreur de syntaxe entretemps mais le problème vient du makefile/de l'installation de la SFML). Je suis sur Windows 7, Mingw installé avec codeblock
Le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include <SFML/Graphics.hpp> using namespace std; 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; }
Le makefile :
et surtout, la sortie de mon makefile :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 CPPFLAGS = -I C:\SFML-2.3.2\include LDFLAGS = -LC:\SFML-2.3.2\lib -lsfml-graphics -lsfml-window -lsfml-system -DSFML_DYNAMIC program : main.o g++ ${LDFLAGS} main.o -o program.exe main.o: main.cpp g++ -c main.cpp ${CPPFLAGS}
J'ai simplement download la SFML puis je l'ai déplacé et j'ai fait mon makefile ci-dessus. Je précise que j'ai téléchargé plusieurs versions de la SFML, mais j'ai surtout essayé avec la version GCC 4.7.1 TDM (SJLJ) - 32-bit, ce qui semble correct d'après gcc -v et ce que j'ai pu lire sur l'installation avec Mingw/CodeBlock. Du coup je suis complètement perdu
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 g++ -c main.cpp -I C:\SFML-2.3.2\include g++ -LC:\SFML-2.3.2\lib -lsfml-graphics -lsfml-window -lsfml-system -DSFML_DYNAMIC main.o -o program.exe main.o:main.cpp:(.text+0x145): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale' main.o:main.cpp:(.text+0x175): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj' main.o:main.cpp:(.text+0x1c3): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE' main.o:main.cpp:(.text+0x20d): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj' main.o:main.cpp:(.text+0x228): undefined reference to `_imp___ZN2sf5Color5GreenE' main.o:main.cpp:(.text+0x232): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE' main.o:main.cpp:(.text+0x25a): undefined reference to `_imp___ZN2sf6Window5closeEv' main.o:main.cpp:(.text+0x27c): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE' main.o:main.cpp:(.text+0x2b8): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh' main.o:main.cpp:(.text+0x2d3): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE' main.o:main.cpp:(.text+0x2f0): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE' main.o:main.cpp:(.text+0x304): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE' main.o:main.cpp:(.text+0x320): undefined reference to `_imp___ZN2sf6Window7displayEv' main.o:main.cpp:(.text+0x32f): undefined reference to `_imp___ZNK2sf6Window6isOpenEv' main.o:main.cpp:(.text+0x371): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev' main.o:main.cpp:(.text+0x3d1): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev' main.o:main.cpp:(.text+0x44b): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev' main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0xe): undefined reference to `_imp___ZTVN2sf11CircleShapeE' main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x1c): undefined reference to `_imp___ZTVN2sf11CircleShapeE' main.o:main.cpp:(.text$_ZN2sf11CircleShapeD1Ev[__ZN2sf11CircleShapeD1Ev]+0x2c): undefined reference to `_imp___ZN2sf5ShapeD2Ev' collect2.exe: error: ld returned 1 exit status make: *** [program] Error 1
Merci d'avance à celui qui me répondra
Partager