I need to access a MySQL database using C. My compiler is MinGW.
So what I have done is get my header files, lib files, and libmysql.dll.
When I try and compile my project, obviously my linking is off. I know that my header files are fine because I managed to get access to the dll's functions the hardway using LoadLibrary() and such.
Code:
#include <windows.h>
#include <stdio.h>
#include <mysql/mysql.h>
typedef MYSQL*(*mysql_init_imp)(MYSQL*);
int main (void)
{
mysql_init_imp mysql_init;
HINSTANCE hinstLib = LoadLibrary("libmysql");
if (hinstLib == NULL)
{
printf("ERROR: unable to load DLL\n");
return 1;
}
mysql_init = (mysql_init_imp)GetProcAddress(hinstLib, "mysql_init");
if (mysql_init == NULL)
{
printf("Unable to load mysql_init()\n");
FreeLibrary(hinstLib);
return 1;
}
FreeLibrary(hinstLib);
return 0;
}
I do not want to do this for every function. I downloaded mysql-noinstall-5.1.30-win32 and am currently trying to figure out how the hell to link them correctly.
I have tried and tried to find this on google but it seems everything I try is failing.
I get the impression that all i need to link is mysqlclient.lib? Could anyone who has done this before push me along in the right direction?