title: Mysql with C++ error: undefined reference to mysql_init
body: <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;mysql.h&gt;
  
  #include &lt;my_global.h&gt;
  
  
  int main (int argc, char *argv[])
  {
  
  MYSQL *conn;
  MYSQL_RES *res;
  MYSQL_ROW row;
  
  char *server = "127.0.0.1";
  char *user = "root";
  char *password = "1386";
  char *database = "OurDB";
  
  conn = mysql_init(NULL);
  
  /* Connect to database */
  if (!mysql_real_connect(conn, server,user, password, database, 0, NULL, 0))
  {
      fprintf(stderr, "%s\n", mysql_error(conn));
      exit(0);
  }
  
    return 0;
  }
  </code></pre>
  
  <p>and i get linker error in codeblocks:</p>
  
  <pre><code>undefined reference to mysql_init
  </code></pre>
  
  <p>I used <code>mysql_config --libs</code> in linker option and <code>mysql_config --cflags</code> in compiler option.</p>
  
  <p>I read somewhere i should add some libraries like libmysql.lib, but i cannot find this file on my PC (I am using Ubuntu 11.04 64bit).</p>