title: Using mysql in c programming
body: <p>I installed ubuntu on a virtual machine. There, I installed mysql server <code>sudo apt-get install mysql-server</code> .This worked, because I could acces <code>mysql-u root -p password</code></p>
  
  <p>After that, I did : <code>sudo apt-get install libmysqlclient-dev</code></p>
  
  <pre><code>#include &lt;my_global.h&gt;
  #include &lt;mysql.h&gt;
  
  int main(int argc, char **argv)
  {
    printf("MySQL client version: %s\n", mysql_get_client_info());
  
    exit(0);
  }
  </code></pre>
  
  <p>When I compile this with  </p>
  
  <pre><code>gcc version.c -o version  `mysql_config --cflags --libs`
  </code></pre>
  
  <p>it works.</p>
  
  <p>But when I compile this one from below</p>
  
  <pre><code>gcc createdb.c -o createdb -std=c99  `mysql_config --cflags --libs`
  </code></pre>
  
  <p>I get some errors.</p>
  
  <pre><code>#include &lt;my_global.h&gt;
  #include &lt;mysql.h&gt;
  
  int main(int argc, char **argv)
  {  
    MYSQL *con = mysql_init(NULL);
  
    if (con == NULL) 
    {
        fprintf(stderr, "%s\n", mysql_error(con));
        exit(1);
    }
  
    if (mysql_real_connect(con, "localhost", "root", "root_pswd", 
            NULL, 0, NULL, 0) == NULL) 
    {
        fprintf(stderr, "%s\n", mysql_error(con));
        mysql_close(con);
        exit(1);
    }  
  
    if (mysql_query(con, "CREATE DATABASE testdb")) 
    {
        fprintf(stderr, "%s\n", mysql_error(con));
        mysql_close(con);
        exit(1);
    }
  
    mysql_close(con);
    exit(0);
  }
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>"Usage:: No such file or directory
  [OPTIONS]: No such file or directory
  Options:: No such file or directory
  [-I/usr/include/mysql: No such file or directory
  [-L/user/lib/x86_64-linux-gnu: No such file or directory
  .
  .
  .
  unrecognized command line option '--cflags'
  unrecognized command line option '--libs'
  .
  .
  unrecognized command line option '--socket'
  unrecognized command line option '--port' "
  </code></pre>
  
  <p>Can someone explain me what I did wrong,and how to fix it?</p>
  
  <p>I just want to get some data from tables in a C program.</p>