I am trying to interact with mariadb database using mariadb connector/c. I have installed mariadb connector using msi file from official site. But bin file of connector is empty. I am new to c coding, if someone knows the reason for bin file to be empty, please suggest me what I can do to solve this?
Following is the code:
#include <stdio.h>
#include <stdlib.h>
#include "C:\Program Files\MariaDB 10.6\include\mysql\mysql.h"
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", "admin",
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);
}
Command I am using to compile is:
gcc -o Dbcon.exe Dbcon.c -I"C:\Program Files\MariaDB\MariaDB Connector C 64-bit\include" -L"C:\Program Files\MariaDB\MariaDB Connector C 64-bit\lib" -lmariadb
I am getting error as:
C:\Program Files\MariaDB\MariaDB Connector C 64-bit\lib\libmariadb.dll: file not recognized: File format not recognized
What wrong I am doing? Can anyone suggest the right way to do this?