Flygamer101 Flygamer101 - 1 month ago 12
C++ Question

SFML 2.1 and Codeblocks Error: sfml-graphics-2.dll is missing from your computer

I've just begun to use c++ and SFML, and everything FINALLY ran fine. Before I would get Undefined Reference Errors, but I realized that I had been downloading the wrong type of SFML, getting SJLJ instead of DW2. The problem was fixed, but was replaced with another; now whenever I run an SFML program, it opens a small windows:

It says:


The program can't start because sfml-graphics-2.dll is missing from
your computer. Try reinstalling the program to fix this problem.


And then when you press "Ok" or closed the window, the program would stop working. NOT TO BE CONFUSED: the program never opened, on the console did.

Here is the Code (probably useless) directly copied and pasted from the codeblocks tutorial site:



#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;
}




Answer

SFML is dynamically linked by default, which means that you need to place sfml-graphics-2.dll (along with the dll files of any other SFML subsystems you use) inside the same directory as your executable.

Comments