I have a game engine written in C++ which I'm porting to Windows (from Mac). It uses C++11 and OpenGL, and for all intents and purposes, it runs!
I'm using a DLL for my game engine which is linked implicitly to the game .exe
at runtime. The problem is, when I try to use a utility class from the DLL, FileSystem
, to find a resource file (a texture, but I don't think it's important), I get this error:
First-chance exception at 0x00007FF9CF988830 (PocoFoundation64.dll) in TestEquinox.exe: 0xC0000005: Access violation reading location 0x000000136A4FF000.
The problem comes when I call this method of my FileSystem
class from the DLL (it's designed to take a filename/partial path and it looks in various places to find the full path):
Poco::Path FileSystem::Get(const std::string &filename) {
std::vector<Poco::Path> paths = {
filename,
ResourceFolder() / filename //<<<<< ERROR HERE
};
for (const Poco::Path &path : paths) {
try {
if (Poco::File(path).exists()) {
return path;
}
} catch (...) { }
}
Logger("FileSystem", std::cerr) << "Could not find file '" << filename << "'!";
return {};
}
Visual Studio shows the error as being at the call of ResourceFolder()
, another method from the same class, also in the DLL. This appears so:
Poco::Path FileSystem::ResourceFolder() {
Poco::Path userData;
//--SNIP-- (other OS's #ifdef'd here)
// GAME->StartupPath is a std::string containing the exe's parent folder
userData = (Poco::Path(GAME->StartupPath).parent() / "Resources").makeDirectory();
//--SNIP-- (and here)
try {
if (!Poco::File(userData).exists()) {
Poco::File(userData).createDirectories();
}
} catch (...) {}
return userData;
}
From the looks of it, it's to do with Poco
's data types not being instantiated properly? I've built it from source with all the same compiler settings (64-bit, multi-byte character set, VS2013), so I don't see how it could be a name mangling/data layout issue.
One more thing to note - I copied the entire FileSystem
class from the DLL to a class local to my game project, called FileSystem2
. Calling FileSystem2::Get
with the same parameters worked correctly and without crashing, despite being the same code.
Hoping someone can point me in the right direction?!
Aucun commentaire:
Enregistrer un commentaire