I'm trying to write a simple script for C to get values from a MySQL database, but it's throwing this error 'undefined reference to `_mysql_init@4''
Don't know if I'm not linking to something I should be? My C knowledge is limited...
I'm using Code Blocks on Windows, here's my code:
#include <winsock.h>
#include <C:\mysql\include\mysql.h>
#include <stdio.h>
#include <string.h>
int main()
{
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
char query[80];
mysql_init(&mysql);
mysql_real_connect(&mysql,"localhost","user","pass","db",0,NULL,0);
sprintf(query,"SELECT src,dst FROM ipaudit");
mysql_real_query(&mysql,query,(unsigned int)strlen(query));
res = mysql_use_result(&mysql);
while(row = mysql_fetch_row(res))
printf("%s %sn",row[0],row[1]);
mysql_free_result(res);
return 0;
}