I use Visual Studio 2017. I have a multi-project solution (c++). There is a project which creates an executable (core app) and projects which create dynamic libraries (plugins). A core app loads plugins at runtime using LoadLibrary
and GetProcAddress
functions. A core app defines an object which contains a map, here is a simplified definition:
class T
{
public:
void fun(const std::string& key)
{
++data_[key];
}
private:
std::map<std::string, int> data_;
};
T object is defined statically in the core app and registered in the plugin (via pointer) which uses it this way:
void Plugin::fun()
{
t->fun(key);
}
The memory allocation takes places when a plugin calls the function but deallocation is performed in the core app. It leads to the following error after closing the app:
That error is not present when I use T object only from the core app.I have found a similar topic but there an error message is a little bit different. A code generation property for the core app and plugin looks this way:
What does it mean that Runtime Library
record is set to different options
with bold font ? How should I set Runtime Library
in the core app and plugin to fix the problem ?