title: Visual Studio C++ link with psapi.lib
body: <p>I have written a C Program which calls the function, GetModuleInformation() which is defined in psapi.h</p>
  
  <p>I am using Microsoft Visual Studio C++ command line compiler (cl.exe) for compiling and linking the program.</p>
  
  <p>I have included the psapi.h header file:</p>
  
  <pre><code>#include &lt;psapi.h&gt;
  </code></pre>
  
  <p>when I try to compile using:</p>
  
  <pre><code>cl program.c
  </code></pre>
  
  <p>It generates the object file, however fails during the linking stage with the error:</p>
  
  <pre><code>program.obj : error LNK2019: unresolved external symbol _GetModuleInformation@16 ref
  erenced in function _main
  program.exe : fatal error LNK1120: 1 unresolved externalsprogram.obj : error LNK2019: unresolved external symbol _GetModuleInformation@16 ref
  </code></pre>
  
  <p>I also place the psapi.lib file in the same folder where the source code file (program.c) is placed, however even then I get the same error message as above.</p>
  
  <p>How do I successfully link it using the command line compiler (cl.exe)?</p>