Showing entries 1 to 2
Displaying posts with tag: mysql.h (reset)
Common Errors and Resolutions for Building your own MySQL or MariaDB C/C++ Program on Windows

In my previous post, Creating a basic C/C++ Program to Interact with MySQL and MariaDB, I ran into some errors along the way, so I wanted to share those and their resolutions.

1. fatal error C1083: Cannot open include file: ‘mysql.h’: No such file or directory

mysql1.c
mysql1.c(2) : fatal error C1083: Cannot open include file: 'mysql.h':
No such file or directory

At this point, my cl command was:

cl /I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
mysql1.c

So I needed to include the directory that contained mysql.h as well. So the above changed to:

cl /I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
/I "C:\Program Files\MySQL\MySQL Server 5.5\include" mysql1.c

2. error C2061: syntax error : identifier ‘SOCKET’

This was actually a small slew of simple syntax errors. …

[Read more]
Creating a basic C/C++ Program to Interact with MySQL and MariaDB

In this post, I’ll cover how to create a simple C/C++ program that interacts with MySQL using the C API (and Connector/C). I discussed in a previous post how to install the C Connector (both SkySQL and MySQL’s), so please refer to that if you are looking for more specifics on that.

So once you have that set up, then there are just a few more things you need to have in order – at least this was the case in my environment.

1. Create a program (this one simply connects to the server and retrieves the server version):

#include <stdio.h>
#include <windows.h>
#include <mysql.h>

MYSQL *conn;
int version = 1;

int main ( int argc, char *argv[] )
{
    conn = mysql_init ( NULL );
    mysql_real_connect ( conn, "localhost", "root",
            "password", "test", 3308, NULL, 0 );
        version = mysql_get_server_version( conn ); …
[Read more]
Showing entries 1 to 2