The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz cannot be located in the dynamic link library sfml-graphics-2.dll

Today I decided to download, install, and try using SFML 2.2. I also downloaded Code :: Blocks with the MinGW compiler. I set everything up and installed it correctly (or, as I thought), and tried to run the sample code to make sure it would work:

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

The code is correctly compiled, although when you try to start it, a window appears with the error message: "The entry point of the procedure _ZSt24__throw_out_of_range_fmtPKcz cannot be located in the dynamic link library sfml-graphics-2.dll". I searched the Internet but did not find anything related to this problem, so I came here to find help. Thanks to further answers.

+6
source share
3 answers

The main cause of this problem is the import libraries for the DLL for another version of the DLL used.

When you created the application, you used the import library so that the linker finds the SFML functions that your application calls. However, the DLL itself does not contain one or more functions for which there are stubs in the import library.

When you create an application that inevitably loads the DLL, a three-step process occurs:

  • Code compilation
  • Code binding
  • Code run

The whole compiler takes care that the program is syntactically correct. This worked without errors.

The linker reference determines whether the functions that you call exist. Here the situation becomes complicated, since there are function stubs in the import library, and this will satisfy the linker. The import library tells the linker: "Yes, this function is located here in this DLL, so trust me." It also worked error free for you.

(Note that this is different from a script other than a DLL where the linker is actually looking for the function itself, not the stub).

However, the actual functions themselves are in another module (DLL), and the only time your application can determine their existence is when you run the program. Here you are stuck right now.

So, first you need to make sure that the import libraries that you use when creating your application match the DLL loaded at runtime. If you still get the error message, contact where you got the DLL and ask how to get the appropriate import libraries.

In addition, there are ways to create an import library from a DLL if, for some reason, you cannot get the import libraries. I don’t know all the details on how to do this manually for MingW, but the information should be available somewhere on the Internet.

+4
source

This is not a direct solution, but a workaround is to try static binding. It looks like an SFML tutorial about this, and it includes adding SFML_STATIC to your #defines section. Your exe will be larger, but they will also be more independent.

I had the same problem and the static link worked, although I used mingw-w64 i686 along with cmake. You downloaded the SFML source code, and then in cmake settings you would:

  • Select source and assembly folders
  • Click "Configure" and for the generator select "CodeBlocks - MinGW Makefiles"
  • turn off BUILD_SHARED_LIBS
  • enable SFML_BUILD_EXAMPLES and SFML_USE_STATIC_STD_LIBS
  • change CMAKE_BUILD_TYPE to Debug (optional, for error messages)
  • click "Customize" then "Create"

The build folder will have a .cbp file. In addition, examples may tell you that either the "resources" folder or openal32.dll are missing, so you just need to add them to the examples in your build folder.

0
source

Essentially, this suggests that your compiler is different from the one that used SFML.

You can solve this problem by downloading a specific version for each. For CodeBlocks, you just download (mingw16.01): http://www.codeblocks.org/downloads/26

For SFML, you just download GCC 4.9.2 TDM (SJLJ): https://www.sfml-dev.org/download/sfml/2.4.2/

0
source

Source: https://habr.com/ru/post/981720/


All Articles