I compile a DLL with mingw 4.5.0 and use it as a Game Maker 8.0 extension. Game Maker dynamically loads the dll. Everything seems to work (the dll functions are called and provide the correct return values), but when I close the Game Maker, a dialog box appears: "Microsoft Visual C ++ Runtime Library", "This application required Runtime to terminate in an unusual way." After that, the process continues to linger in the background for several seconds, and then disappears.
This also happens when none of the dll functions are actually called. No DllMain, and all static / global variables are basic data types or std::string(this also happens when I delete std :: string).
dll statically binds to zlib and libpng. The problem seems to disappear when I pass -static to the linker, which (I suppose) also binds static at runtime. However, this greatly inflates the size of my DLL, and this is at best a workaround until I understand what is happening.
Any ideas on what could be causing?
Refresh . In fact, it seems that the problem only arises when two extensons are loaded into Game Maker: one with a dll associated with -static, and the other without it. Linking both without static eliminates the problem. However, I still don't understand the problem, because dlls never interact directly or share data structures.
Update 2 . I recently found out that this could be due to the strange behavior of the Game Maker itself. It seems that the global variables are not initialized correctly when loading the DLL, which can lead to an unloading failure if the global objects try to free memory that they do not own. This would mean that the -stat was just a random factor that changed the value of the uninitialized memory that global variables are associated with.
3. , , Game Maker, , , 2.