Kataware
Kataware

Reputation: 187

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

Upvotes: 4

Views: 30541

Answers (4)

Rahul Kumar
Rahul Kumar

Reputation: 11

Best option is Copy All the .dll files from SFML-2.4.2 > bin. And past them to C: > Windows > System32 folder. That's all you need to do. Then Run your Program. you will be able to run it.

Upvotes: 1

Sajidur Rahman
Sajidur Rahman

Reputation: 3060

Copy all dll files from main SFML > bin directory and paste them into your project folder. In my case it is C:\Users\myname\Documents\Visual Studio 2017\SFML\SFML enter image description here

and if you want to run just the exe file. Place all dll files the same directory as the main exe file.

Upvotes: 12

C. Newby
C. Newby

Reputation: 1

I had a similar problem. My error was when I was linking the libraries in the Compiler setting I had forgot to add the suffix "-s-d". This ending allows the compiler and debugger to function properly.

Upvotes: 0

Julian
Julian

Reputation: 1736

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.

Upvotes: 12

Related Questions