title: Loading DLL not initializing static C++ classes
body: <p>I have a DLL that is being loaded at run-time. The DLL relies on a static variable for internal workings (it is a std::map), this variable is defined within the DLL.</p>
  
  <p>When I call the first function from the DLL after loading, I get a SegFault from the DLL, the map was never initialized. From everything I have read from DLL Loading, static and global data initialization should happen before even the call to DLLMain.</p>
  
  <p>To test static initialization I added a static struct that prints out a message, and even threw in a breakpoint for good measure.</p>
  
  <pre><code>static struct a
  {
    a(void) { puts("Constructing\n"); }
  }statica;
  </code></pre>
  
  <p>There was no message, or break before DLLMain or the function is called.</p>
  
  <p>Here is my loading code:</p>
  
  <pre><code>  dll = LoadLibrary("NetSim");
    //Error Handling
  
    ChangeReliability   = reinterpret_cast&lt;NetSim::ChangeReliability&gt;
                          (GetProcAddress(dll, "ChangeReliability"));
  
  
  ChangeReliability(100);
  </code></pre>
  
  <p>I have verified that the dll version is the correct one, rebuilt the entire project multiple times, but no difference. I am fresh out of ideas.</p>