SFML "cannot find sfml-graphics-2.dll"

So I have followed the tutorial on the website of sfml and I am still running into this problem.
I have been told I need to put it into the .exe, but I really have no idea what that means or even what that is.
I used echo %PATH% and saw that one of the paths used MinGW\bin so I copied and pasted "sfml-graphics-2.dll" in there, it still didn't work, so obviously that's not the right thing to do.
So my question is, what/where is this .exe?
Where will i find it?
Help as soon as possible would be awesome!
Any C++ program needs to be a compiled into a .exe (on windows) to be able to run.

If you're dynamically linking SFML, you need to put sfml-graphics-2.dll inside the same folder as your .exe file. We can't tell you where your .exe file, but if you're using codeblocks, then the default place it puts it is in [project directory]/bin/release. Note that when working with IDEs, it might make your working directory the same place as the file project (.cbp), so try copying your DLL files to there, too.

Edit: After browsing the forum, it seems like you have multiple topics about almost the same thing. Try to stick to one..
Last edited on
Well, for a start I'm not getting anywhere on my other threads, so I started fresh hoping others could help.
Anyway,
I went to where codeblocks saves my projects:
C:\Users\Danny\Documents\C++
In there was a bunch of folders, of cours all my projects, so I opened on up and it contained:
(folder) bin
(folder) obj
arrays.cbp
arrays.depend
arrays.layout
main.cpp
(project is called arrays)
so I pasted it in there and it still didnt work.
Do I have to open up bin, then debug, then paste it there, as I noticed thats where the .exe was!?
Okay, after a bit of toying around, I'm now getting this problem:
"undefined reference to glReadPixels@28"
and a bunch of others underneath that, is this another file I have to copy over?
42 files, to be specific :/
Last edited on
Well I feel for you as getting libraries to work with c++ is a nightmare!
If you get it working perhaps you can explain it to me!
This is not an issue when using other languages.
I remember with DevCPP they had devpaks that automated the task.

When I downloaded SFML, followed the instructions for installing it and then ran the code below in the code::blocks IDE I got,
"The program can't start because sfml-system-2.dll is missing from your computer."

However this is not true for a search found it in C:\SFML-2.3.1\bin


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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;
}
Last edited on
@CodeWriter your ide doesn't search your entire computer for the dll file. You need to put the dll in the same place as your exe file.
My sfml project is in the same folder path,
C:\SFML-2.3.1\examples\novice\testSFML\testSFML.cbp
I just copied the .dll into the same folder but the same error message.
I notice there are eleven .dll files in the C:\SFML-2.3.1\bin folder.
I also copied the .dll into the windows system32 folder where I thought all compilers checked for such things.
Should I have placed this in another new post?
Although related to this thread and maybe of use to DannyL I don't want to hijack his thread.
Last edited on
@DannyL, now your problem is OpenGL headers/stuff. Yeah linking is a bitch sometimes especially being a beginner, I feel for you too.

The undefined references to OpenGL stuff means that it's not reading glew.h, I believe. I have my glew.h file in [MinGW directory]/include/GL/glew.h

Under Project -> Build Options -> Release -> Linker Settings, do you have "opengl32" somewhere in there? If not, it needs to be added, after the other sfml links.
Also, in [MinGW directory]/lib/, do you have the file "libopengl32.a"?

I'm throwing out ideas, as you can imagine this stuff is hard to communicate over the internets.
Last edited on
Actually SFML 2.3 and later doesn't need GLEW, could you post your build settings here as screenshots? I'd recommend linking statically, it gets rid of (almost) all the annoying dlls. Check through all your settings, they should match these:
Search Directories -> Compiler
path ending in SFMl/include
Search Directories -> Linker
path ending in SFML/lib
Linker settings (release)
sfml-graphics-s
sfml-window-s
sfml-system-s
opengl32
freetype
jpeg
winmm
gdi32
Linker settings (debug)
sfml-graphics-s-d
sfml-window-s-d
sfml-system-s-d
opengl32
freetype
jpeg
winmm
gdi32
Compiler settings -> #defines
SFML_STATIC

Additionally, you should be using an empty project, not an SFML project or any of the other templates.
Topic archived. No new replies allowed.