本来是非常兴致勃勃的来整C++的,,,结果太失望了,,,
mysql的C++接口是有bug的,我艹,,,
虽然不知道是什么问题,但是对照源代码查看是完全不可能出现的情况,,,遂很伤心,,,折腾大半夜重新编译安装以后解决,,,很伤心,,,
配置C接口也遇到一个问题:
c:\program files\mysql\mysql server 5.0\include\mysql_com.h(175) : error C2146: syntax error : missing ';' before identifier 'fd'
c:\program files\mysql\mysql server 5.0\include\mysql_com.h(175) : error C2501: 'SOCKET' : missing storage-class or type specifiers
c:\program files\mysql\mysql server 5.0\include\mysql_com.h(175) : error C2501: 'fd' : missing storage-class or type specifiers
c:\program files\mysql\mysql server 5.0\include\mysql_com.h(339) : error C2065: 'SOCKET' : undeclared identifier
c:\program files\mysql\mysql server 5.0\include\mysql_com.h(339) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\mysql\mysql server 5.0\include\mysql_com.h(340) : error C2059: syntax error : ')'
等错误
解决方法:
1. 确定配置正确
1)project-->properties-->configuration properties-->c/c++-->general-->additional include directories中填写"C:\Program Files\MySQL\MySQL Server 5.0\include" 红色部分改成你自己安装MySQL时候的路径
2)project-->properties-->configuration properties-->Linker-->General-->additional library directories中填写"C:\Program Files\MySQL\MySQL Server 5.0\lib\debug" 红色部分改成你自己安装MySQL时候的路径
3)project-->properties-->configuration properties-->Linker-->input-->additional dependencies 中填写 libmysql.lib 把这个文件从mysql的安装目录下copy到C:\WINDOWS\system32目录下.
2. 确定在程序的头文件中含有
#include <winsock.h>
#include "mysql.h"