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.
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.
int main (void)
HINSTANCE hinstLib = LoadLibrary("libmysql");
if (hinstLib == NULL)
printf("ERROR: unable to load DLL\n");
mysql_init = (mysql_init_imp)GetProcAddress(hinstLib, "mysql_init");
if (mysql_init == NULL)
printf("Unable to load mysql_init()\n");
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?