Mysql的语法规则可参考:http://dev.mysql.com/doc/refman/5.0/en/c-api-function-overview.html
Mysql++的官网为http://tangentsoft.net/mysql++/
mysql++-3.2.2.tar.gz (3.1 MB, 2015.03.18) — Library source code. If you aren’t sure which file to download, download this.
编译是一个坑,花了我整整一小时!
特别注意原生的解压包是x64的,而我的mysql是32位的,所以只好自己拷过来了,不然链接会出错
1.自建一个dll工程mysqlpp,把所有的文件全删除掉,把mysql++中的lib文件夹复制过来
2.mysqlpp设置包含路径.\lib
3.设置依赖路径,就是自己的mysql安装路径中include和lib到VC++目录,注意平台选win32
4.修改工程属性:添加依赖项:libmysql.lib 和 ws2_32.lib
5.在common.h的最开始处加上:
#include <WinSock2.h> #include <windows.h>
#ifdef MYSQLPP_MAKING_DLL // When making the DLL, export tagged symbols, so they appear // in the import library. #define MYSQLPP_EXPORT __declspec(dllexport) #elif !defined(MYSQLPP_NO_DLL) // We must be _using_ the DLL, so import symbols instead. #define MYSQLPP_EXPORT __declspec(dllimport) #else // Not making a DLL at all, so no-op these declspecs #define MYSQLPP_EXPORT #endif
所以这个宏MYSQLPP_MAKING_DLL是要带上的!
debug:
WIN32 _USRDLL DLL_EXPORTS _DEBUG UNICODE _UNICODE MYSQLPP_MAKING_DLL HAVE_MYSQL_SSL_SETrelease:
WIN32 _USRDLL DLL_EXPORTS UNICODE _UNICODE MYSQLPP_MAKING_DLL HAVE_MYSQL_SSL_SET