title: undefined reference to 'XXX' after using #define _GNU_SOURCE
body: <p>I used <code>search.h</code> for my c program, where I need to put <code>#define _GNU_SOURCE</code> to the first line in order to introduce multiple hash tables. But after that, errors like <code>undefined reference to 'log10'</code> and <code>undefined reference to 'PQntuples'</code> popped up. I certainly need all the packages there, how should I now compile the program? Any help would be deeply appreciated! Thanks.</p>
  <p>The headers:</p>
  <pre><code>#define _GNU_SOURCE
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;math.h&gt;
  #include &lt;string.h&gt;
  // library for psql
  #include &lt;libpq-fe.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;time.h&gt;
  #include &lt;search.h&gt;
  
  </code></pre>
  <pre><code>int main(void){
      char host[] = &quot;localhost&quot;;
      char port[] = &quot;5432&quot;;
      char db_name[] = &quot;db_name&quot;;
      char user[] = &quot;test_usr&quot;;
      char password[] = &quot;123456&quot;;
      sprintf(db_str, &quot;host=%s port=%s dbname=%s user=%s password=%s&quot;,
               host, port, db_name, user, password);
      PGconn *db_connection = DBConnect(db_str);
  
      struct hsearch_data htab;
      hcreate_r(10, &amp;htb);
      ENTRY e, *ep;
      e.key = &quot;test&quot;;
      e.data = (void *) 1;
      hsearch_r(e, ENTER, &amp;ep, &amp;htab);
  }
  
  </code></pre>
  <p>And this was how I compile the file:</p>
  <pre><code>gcc -Wall -Wextra -I/home/userX/postgresql/include -L/home/userX/postgresql/lib -lm -lpq -g my_program.c
  
  </code></pre>