I have a dll that loads at runtime. The DLL relies on a static variable for internal operations (this is std :: map), this variable is defined in the DLL.
When I call the first function from the DLL after loading, I get SegFault from the DLL, the card was never initialized. From everything that I read from DLL Loading, static and global data initialization should occur before DLLMain is called.
To test static initialization, I added a static structure that displays a message and even throws a breakpoint for good measure.
static struct a { a(void) { puts("Constructing\n"); } }statica;
There was no message or there was no break before calling the DLLMain or function.
Here is my download code:
dll = LoadLibrary("NetSim"); //Error Handling ChangeReliability = reinterpret_cast<NetSim::ChangeReliability> (GetProcAddress(dll, "ChangeReliability")); ChangeReliability(100);
I checked that the dll version is correct, recompiled the entire project several times, but it makes no difference. I am fresh from ideas.
c ++ static dll winapi
Ramon Zarazua B.
source share