Version Codeblocks: 16,01 Version SFML: 2.4.2SFML Projet Codeblocks ne fonctionne pas
J'ai créé un projet SFML 2.0 Codeblocks. J'ai sélectionné Nouveau projet-> SFML Project-> SFML 2.0. J'ai copié ce code dans le fichier main.cpp et l'ai compilé.
#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;
}
Quand je construit le code que j'ai obtenu les erreurs suivantes:
> -------------- Build: Debug in aaa (compiler: GNU GCC Compiler)---------------
>
> mingw32-g++.exe -LC:\sfml\SFML-2.4.2\lib -o bin\Debug\aaa.exe
> obj\Debug\main.o -lmingw32 -luser32 -lgdi32 -lwinmm -ldxguid
> C:\sfml\SFML-2.4.2\lib\libsfml-graphics.a
> C:\sfml\SFML-2.4.2\lib\libsfml-window.a
> C:\sfml\SFML-2.4.2\lib\libsfml-system.a -lsfml-graphics-s-d
> -lsfml-window-s-d -lsfml-system-s-d -lsfml-main-d obj\Debug\main.o: In function `main': C:/Users/my/Documents/codeblocks/aaa/main.cpp:5:
> undefined reference to `sf::String::String(char const*, std::locale
> const&)' C:/Users/my/Documents/codeblocks/aaa/main.cpp:5: undefined
> reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int,
> unsigned int)' C:/Users/my/Documents/codeblocks/aaa/main.cpp:5:
> undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode,
> sf::String const&, unsigned int, sf::ContextSettings const&)'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:6: undefined reference
> to `sf::CircleShape::CircleShape(float, unsigned int)'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:7: undefined reference
> to `sf::Color::Green' C:/Users/my/Documents/codeblocks/aaa/main.cpp:7:
> undefined reference to `sf::Shape::setFillColor(sf::Color const&)'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:15: undefined reference
> to `sf::Window::close()'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:12: undefined reference
> to `sf::Window::pollEvent(sf::Event&)'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:18: undefined reference
> to `sf::Color::Color(unsigned char, unsigned char, unsigned char,
> unsigned char)' C:/Users/my/Documents/codeblocks/aaa/main.cpp:18:
> undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:19: undefined reference
> to `sf::RenderStates::Default'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:19: undefined reference
> to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates
> const&)' C:/Users/my/Documents/codeblocks/aaa/main.cpp:20: undefined
> reference to `sf::Window::display()'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:9: undefined reference
> to `sf::Window::isOpen() const'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:23: undefined reference
> to `sf::RenderWindow::~RenderWindow()'
> C:/Users/my/Documents/codeblocks/aaa/main.cpp:23: undefined reference
> to `sf::RenderWindow::~RenderWindow()' obj\Debug\main.o: In function
> `ZN2sf11CircleShapeD1Ev':
> C:/sfml/SFML-2.4.2/include/SFML/Graphics/CircleShape.hpp:41: undefined
> reference to `vtable for sf::CircleShape'
> C:/sfml/SFML-2.4.2/include/SFML/Graphics/CircleShape.hpp:41: undefined
> reference to `vtable for sf::CircleShape'
> C:/sfml/SFML-2.4.2/include/SFML/Graphics/CircleShape.hpp:41: undefined
> reference to `sf::Shape::~Shape()' collect2.exe: error: ld returned 1
> exit status Process terminated with status 1 (0 minute(s), 0
> second(s)) 20 error(s), 0 warning(s) (0 minute(s), 0 second(s))
J'ai essayé d'utiliser les versions statiques et dynamiques, sans succès. Qu'est ce qui ne s'est pas bien passé?
Possible copie de [Qu'est-ce qu'une erreur de symbole externe de référence non résolue/non résolue et comment la réparer?] (Https://stackoverflow.com/questions/12573816/what-is-an-un-défini-référence-non résolu-externe-symbole-erreur-et-comment-faire-je-fix) – alseether