title: C++ - LoadLibrary returns 126 error for self-made DLL
body: <p>I'm playing in custom project and trying to create a DLL in other project and link in runtime using <code>LoadLibrary</code> function, but it returns 126 error. In googled a lot, but in the most cases people debugged programs of others. But my DLL contains function <code>string sayHello() { return "Hello"; }</code>. Which project options should be applied to let me successfully load this dll? And call the function? Thanks</p>
  
  <p>UDP:</p>
  
  <pre><code>vector&lt;BYTE&gt; decodedDll = base64_decode(base64dll);
  string filename = string("lib.dll");
  ofstream outfile(filename, ios::out | ios::binary);
  outfile.write((const char*) &amp;decodedDll[0], decodedDll.size());
  outfile.close();
  if (!fileExists(filename))
  {
      cout &lt;&lt; "DLL file not found " &lt;&lt; endl;
      getchar();
      return;
  }
  HINSTANCE hGetProcIDDLL = LoadLibrary((LPCWSTR) filename.c_str());
  int loadLibraryError = GetLastError();
  if (hGetProcIDDLL == NULL)
  {
      string error = "Could not load DLL\n";
      send(s, error.c_str(), error.length(), 0);
      finishSocketWork(s, address);
      cout &lt;&lt; "Unable to load LIB, error code " &lt;&lt; loadLibraryError &lt;&lt; endl;
      getchar();
      return;
  }
  </code></pre>
  
  <p>(it's a university work, I'm required to receive DLL from client, call specified function and return result). And .dll transfer works good -- files are equal</p>