title: How to get mysql C api working on WINDOWS?
body: <p>Below is my small piece of 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>As evident, the only objective is to get this small program up and running, so nothing much to boast about.But to my dismay it became a headache for me. First I got an error which I posted as this <a href="https://stackoverflow.com/questions/30678557/binary-log-types-h-no-such-file-or-directory">SO question</a> which I fortunately resolved. Now I am getting a stream of errors as
  described below :</p>
  
  <pre><code>-------------- Build: Debug in mysqlconntest (compiler: GNU GCC Compiler)---------------
  
  gcc.exe -Wall -fexceptions -g -I"C:\Program Files (x86)\MySQL\MySQL Server 5.7\include" -I"C:\Program Files (x86)\MySQL\MySQL Server 5.7\include" -c C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp -o obj\Debug\main.o
  In file included from C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp:2:0:
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h:211:19: error: conflicting declaration 'typedef int mode_t'
  In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/io.h:20:0,
                   from C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h:32,
                   from C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp:2:
  c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/sys/types.h:99:17: error: 'mode_t' has a previous declaration as 'typedef _mode_t mode_t'
  In file included from C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp:2:0:
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h:212:19: error: conflicting declaration 'typedef SSIZE_T ssize_t'
  In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/io.h:20:0,
                   from C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h:32,
                   from C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp:2:
  c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/sys/types.h:118:18: error: 'ssize_t' has a previous declaration as 'typedef _ssize_t ssize_t'
  In file included from C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp:2:0:
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h: In function 'tm* localtime_r(const time_t*, tm*)':
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h:644:25: error: 'localtime_s' was not declared in this scope
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h: In function 'tm* gmtime_r(const time_t*, tm*)':
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/my_global.h:650:22: error: 'gmtime_s' was not declared in this scope
  In file included from C:\Users\Sajith\Documents\CodeBlocks\mysqlconntest\main.cpp:3:0:
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h: At global scope:
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:252:3: error: 'NET' does not name a type
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:277:25: error: 'SCRAMBLE_LENGTH' was not declared in this scope
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:415:48: error: use of enum 'enum_session_state_type' without previous declaration
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:419:47: error: use of enum 'enum_session_state_type' without previous declaration
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:441:45: error: use of enum 'mysql_enum_shutdown_level' without previous declaration
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:448:12: error: use of enum 'enum_mysql_set_option' without previous declaration
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:580:28: error: 'NET' has not been declared
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:634:21: error: 'MYSQL_ERRMSG_SIZE' was not declared in this scope
  C:\Program Files (x86)\MySQL\MySQL Server 5.7\include/mysql.h:635:19: error: 'SQLSTATE_LENGTH' was not declared in this scope
  Process terminated with status 1 (0 minute(s), 0 second(s))
  15 error(s), 0 warning(s) (0 minute(s), 0 second(s))
  </code></pre>
  
  <p>Below are the things which I have done.</p>
  
  <ol>
  <li>Went through <a href="http://gluescript.sourceforge.net/?q=node/39" rel="nofollow noreferrer">this</a> tutorial to create a libmysql.a file.</li>
  <li><p>Verified my include directoried and linker libraries.<br></p>
  
  <p><strong>Linkers</strong></p>
  
  <p><img src="https://i.stack.imgur.com/qHeFP.png" alt="Linker1"></p>
  
  <p><img src="https://i.stack.imgur.com/Fr5PD.png" alt="Linker2"></p>
  
  <p><strong>Include Directories</strong></p>
  
  <p><img src="https://i.stack.imgur.com/fTKb7.png" alt="Include Directories"></p></li>
  </ol>
  
  <p>This made me think that I didn't do my homework properly before I jumped into MySQL API programming. What am I missing here? What are the very basic things that I should ensure before I compile a MYSQL application. I was able to compile this program in my Linux machine successfuly. So I guess that this is Windows specific problem. Any help appreciated.</p>
  
  <p><strong>Note:</strong> I am using Code::Blocks (with MingGW toolchain) for an IDE and Windows 8.1 64Bit for an OS. MySQL is 32 bit and my application too is 32 bit.</p>