Conditions of the problem:
- Downloaded and unzipped ‘SFML (Version 2.5.1)’ for ‘GCC 7.3.0 MinGW (SEH) – 64-bit’ from official website
- Copied dll files into my own project folder containing main.cpp which uses SFML
- Also copied include and lib folders into the src folder of my project folder
- Installed MinGW-w64 via chocolatey (choco install mingw)
- Added the bin folder to the environment variables for this account (path)
- Compiled project with: g++ -std=c++23 -Wall -Wextra -I src/include *.cpp -o wizard.exe -L src/lib -lsfml-graphics -lsfml-window -lsfml-system
main.cpp:
#include <SFML/Window.hpp>
int main()
{
sf::Window window(sf::VideoMode(800, 600), "My window");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
}
return 0;
}
Everything looks good up to this point, the compilation works.
How to trigger the error:
When you try to run the program you get the error message that the procedure entry point in a DLL could not be found. This makes the executable file useless.
Question:
How to solve this problem? Unfortunately, the reasons for the error are not explained more detailed.
Approaches already tried:
As a solution, I have already tried reinstalling MinGW via MSYS2. But even with that, the compilation worked, but the execution resulted in the same error.
1
After searching and trying for a long time, I was now able to solve the problem myself:
Do not install MinGW via choco install mingw
, as this will install a version that is too new (e.g. 14.1.0).
Instead, install an older Version of mingw, e.g. choco install --version 11.1.0
The error occurs due to an incompatibility of the SFML and the mingw versions.
The SFML website recommends using mingw 7.3.0, but the C++ standard std=c++23 is not yet available there.
Through trial and error, I found that the incompatibility starts at 12.x.x, which is why I recommend an 11.x.x version of mingw.