title: undefined reference to `PQconnectdb'
body: <p>Recently a project that i am working on requred to add postgresql support to it. Project is written in C(its open source<a href="https://github.com/meetecho/janus-gateway" rel="nofollow noreferrer">Janus gateway</a>).</p>
  
  <p>I follwed these steps to install the postgress and libps-dev.</p>
  
  <pre><code>sudo apt-get install postgresql
  sudo apt-get install libpq-dev
  $ sudo -u postgres psql postgres
  psql (9.3.9)
  Type "help" for help.
  
  postgres=# \password postgres
  </code></pre>
  
  <p>Then in my header(connect.h) file:</p>
  
  <pre><code>#include &lt;postgresql/libpq-fe.h&gt;
  #include "debug.h"
  
  /*! \brief Connect to postgresql database
   * If successfull, returns PGconn type
   * If not exits the program
   * @param[in] postgres connection params, ex. username, db, host, etc.
   */
  PGconn *connect_to_database(gchar connection_params);
  
  /*! \brief Closes connection to database
   * @param[in] PGconn instance
   */
  PGconn *close_connection_to_database(PGconn *pgconn);
  </code></pre>
  
  <p>And my .c(connect.c) file:</p>
  
  <pre><code>/*! \file    db.c
   * \author   ...
   * \copyright GNU General Public License v3
   * \brief    Event handler notifications (headers)
   * \details  This file contains methods for safely creating databse connection
   * to postgresql and then closing it.
   * 
   * \ingroup db
   * \ref db
   */
  
  #include "./connect.h"
  
  PGconn *connect_to_database(gchar connection_params) {
    JANUS_LOG(LOG_WARN, "TESTINGSSS \n\n\n\n");
  
  
    const char test_connect = "testings";
  
    PGconn *conn = PQconnectdb(test_connect);
  
    return conn;
  }
  </code></pre>
  
  <p>On <code>make</code> i get:</p>
  
  <pre><code>todns@todnnns-VirtualBox ~/Projects/janus-gateway $ make
  make  all-recursive
  make[1]: Entering directory '/home/todns/Projects/janus-gateway'
  Making all in html
  make[2]: Entering directory '/home/todns/Projects/janus-gateway/html'
  make[2]: Nothing to be done for 'all'.
  make[2]: Leaving directory '/home/todns/Projects/janus-gateway/html'
  make[2]: Entering directory '/home/todns/Projects/janus-gateway'
    CCLD     janus
  db/janus-connect.o: In function `connect_to_database':
  /home/todns/Projects/janus-gateway/db/connect.c:20: undefined reference to `PQconnectdb'
  collect2: error: ld returned 1 exit status
  Makefile:1195: recipe for target 'janus' failed
  make[2]: *** [janus] Error 1
  make[2]: Leaving directory '/home/todns/Projects/janus-gateway'
  Makefile:1914: recipe for target 'all-recursive' failed
  make[1]: *** [all-recursive] Error 1
  make[1]: Leaving directory '/home/todns/Projects/janus-gateway'
  Makefile:905: recipe for target 'all' failed
  make: *** [all] Error 2
  </code></pre>
  
  <p>The problem is:</p>
  
  <pre><code>db/janus-connect.o: In function `connect_to_database':
      /home/todns/Projects/janus-gateway/db/connect.c:20: undefined
  </code></pre>
  
  <p>My gut is telling me, that it has something to do with Makefile.am file, but i dont really know what to change there.
  So the question is: What am i missing in this setup? How can i link postgres-dev library with my C code?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong> Forgot to mention, i am running this on Linux Mint virtual machine( main machine is a macbook pro).</p>