【发布时间】:2018-05-12 22:33:15
【问题描述】:
需要帮助:
我需要使用基本 C 程序在 Visual Studio 2013 上使用 connector/C 连接到 MySQL 5.7。我收到与 my_global.h 相关的错误。
我试图在谷歌上找到解决方案,但我没有成功。
我的步骤:
我从 MySQL 网页下载了 MySQL 5.7,并成功安装了它的 msi 安装程序。
我从 MySQL 网页下载了它的 Connector/C 并成功安装了它的 msi 安装程序。我发现Connector/C是由头文件(包含文件)和一个库文件(libmysql)组成的。
我按照tutorial (stackoverflow supported answer)链接库并将文件包含到 Visual Studio 2013 中。
我在Visual Studio 2013上写了以下代码
#include <my_global.h> #include <mysql.h> int main(int argc, char **argv) { MYSQL *conn; conn = mysql_init(NULL); if (conn == NULL) { printf("Error %u %s\n", mysql_errno(conn), mysql_error(conn)); exit(1); } if (mysql_real_connect(conn, "localhost", "root", "asdfasdf", NULL, 0, NULL, 0) == NULL) { printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn)); exit(1); } if (mysql_query(conn, "CREATE DATABASE testdb")) { printf("Error %u: %s", mysql_errno(conn), mysql_error(conn)); exit(1); } mysql_close(conn); return 0; }
它给出了错误: 错误 2 错误 C2037: 'tv_nsec' 左侧指定未定义的结构/联合 'timespec' c:\program files\mysql\mysql 连接器 c 6.1\include\my_global.h 698 1 mysql
您能帮忙解决以下问题吗:
我在谷歌上搜索并找不到任何具体的教程。我搜索了谷歌、youtube 和 stackoverflow。 MySQL Reference Manual 对入门没有帮助。你能在这个问题上给我建议和支持吗?
是否有任何一本(只有一本)关于使用 C 编程连接到 MySQL 的电子书或书籍?
感谢您的帮助!
【问题讨论】:
标签: mysql visual-studio-2013 mysql-connector mysql-connector-c