Visual C++ MySQL compilation issues - need guidance

Having trouble with MySQL compilation in Visual C++

I’m working on a database application using Visual C++ and MySQL connector. I’ve set up the project with the necessary library files and include directories, but I keep running into compilation errors.

Here’s my basic test code:

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

int main()
{
    MYSQL connection;
    return 0;
}

The compiler throws these errors:

error C2065: 'MYSQL' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'connection'
error C2065: 'connection' : undeclared identifier

I’ve already added mysql.lib to the linker dependencies and configured the include paths in project properties. What am I missing in my setup? Any help would be appreciated.

Double-check your header file first. You want mysql/mysql.h or just mysql.h depending on where MySQL’s installed. Make sure your include directory actually points to where the MySQL headers live - I’ve been burned by paths that pointed to empty folders before. Also watch out for 32-bit vs 64-bit mismatches between your project and the MySQL connector you downloaded. Quick test: try the full path in your include statement to see if it finds the header.