title: Link against a 3rd-party library with Visual Studio
body: <p>I'm trying to create a .dll with Visual Studios 2013. The project includes libpq functionality. </p>
  
  <p>Per other stackoverflow posts, and other sources I've found on the internet, I've (as far as I'm aware) correctly added the postgres lib and include directories to the project. However, when I go to build the project, it returns a number of "unresolved external symbol" errors. </p>
  
  <p>My paths are <code>C:\Program Files\PostresSQL\9.3\...</code> so I have them surrounded by quotation marks in the Additional Library/Include Directory fields. I've included the <code>libpq-fe.h</code> header file in the project... I'm just not sure what I'm doing wrong. </p>
  
  <p>Another note, I can compile a test program from the command line using g++ with the -I, -L, and -lpq flags, but I'm not sure how to compile to a .dll from the command line (plus it adds complexity that I just don't want to deal with).</p>
  
  <p>These are the specific errors I'm getting: </p>
  
  <pre><code>1&gt;sql_arma.obj : error LNK2001: unresolved external symbol _PQconnectdb
  1&gt;sql_arma.obj : error LNK2001: unresolved external symbol _PQstatus
  1&gt;sql_arma.obj : error LNK2001: unresolved external symbol _PQerrorMessage
  1&gt;sql_arma.obj : error LNK2001: unresolved external symbol _PQfinish
  1&gt;C:\Users\tills13\documents\visual studio 2013\Projects\sql_arma\Release\sql_arma.dll : fatal error LNK1120: 4 unresolved externals
  </code></pre>
  
  <p>I have, as suggested below, included <code>#pragma comment(lib, "libpq.lib")</code> in the source file for my project, I still receive these errors. </p>