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

穿精又带淫゛_ 提交于 2019-12-14 02:21:02

问题


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

回答1:


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.




回答2:


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

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




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/29242013/sfml-2-1-and-codeblocks-error-sfml-graphics-2-dll-is-missing-from-your-computer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!