昨天忘了在看什么的时候发现了在/usr/include/中有个mysql++的文件夹,google之发现原来这个是mysqlpp,一个C++的用来访问MySQL的第三方的库。google到的提供支持的是这个网站http://tangentsoft.net/mysql++/。上面有详细的文档。貌似这个也是有官方支持的,在mysql的官网的emaillist中发现好多关于这个库的。
之前也有弄过官网的mysql connector for c++,但是弄了好久没有弄好,到处搜解决方案,不过网上关于mysql C API的很多,关于这个c++ connector的很少。后来发现据说是官网上的这么一句话的原因:
One problem that can occur is when the tools you use to build your application are not compatible with the tools used to build the binary versions of MySQL Connector/C++. Ideally, you need to build your application with the same tools that were used to build the MySQL Connector/C++ binaries.
但是最后也没有弄好。现在用这个mysqlpp,首先看名字就觉得很优雅,使用起来也确实很好用。文档齐全,平台支持好(我只在ubuntu下使用过,其他平台没有使用过),关键是使用起来真的很方便。这个库是在C API上的一层包装,因此必须有C API,也就是装了mysql server之后在/usr/include/mysql下的一堆文件(以及相应的.lib.so.a文件)。
开始使用MySQLpp
这里将我刚开始接触的一些问题写一下,其实也没碰到多少问题,很容易上手。在文档中copy了一个例子:build and run,出现了下面的错误:
/usr/include/mysql++/common.h|131|致命错误: mysql_version.h:没有那个文