title: Explicitly Load Library (DLL) into Legacy function pointers
body: <p>I will try to be as specific as possible.</p>
  
  <p>I need to explicitly load a PythonXX.dll at run-time into my routine.  I am using the nominal descriptions (Python.h) to describe the functions.  The problem is that the linker complains that these routines are not present.  I cannot change the function definitions to make the linker happy, because there are scattered about the Python #include code structure.</p>
  
  <p>My thinking at this point is to create stub routines that call a function pointer to be loaded when the .dll is loaded at run-time.  The stubs make the linker happy, and they operate correctly when the .dll is loaded during run-time. 
   But this has some problems too. [Some functions are #defines of other routines, varags are difficult to redirect, etc.]</p>
  
  <p>Is there a better way to do this?  I can't believe this hasn't occurred before.  If anything is unclear, I will edit and clean up the question to clarify.</p>
  
  <p>Update:  OK, this seems to work, at least with some of the routines. (Fortunately, I only need to use about 20 of the 1000+ functions of the .dll)</p>
  
  <p>An example function pointer definition:</p>
  
  <pre><code>int (__cdecl *pPy_IsInitialized)(void);
  </code></pre>
  
  <p>An example stub:</p>
  
  <pre><code>int Py_IsInitialized()
  {
    return pPy_IsInitialized();
  }
  </code></pre>
  
  <p>An example assignment  (dll is return from LoadLibrary() ):</p>
  
  <pre><code>pPy_IsInitialized = (void *)GetProcAddress(dll,"Py_IsInitialized");
  </code></pre>