0

我正在尝试使用 SOCI 库来轻松访问 MySQL,但我一直在安装该库。

到目前为止我所做的是:

  • 制作项目并用 CMake 编译
  • 将我的项目链接到编译后创建的 lib/release 目录。
  • 将我的项目链接到 MySQL C 连接器 lib 目录

这是我的附加包含目录: http: //puu.sh/6qGNP.png

但是不知何故,当我编译示例程序时,我得到了一堆像这样的链接器错误:

1>main.obj : 错误 LNK2019: 未解析的外部符号“public: virtual __thiscall soci::details::standard_into_type::~standard_into_type(void)” (??1standard_into_type@details@soci@@UAE@XZ) 在函数中引用公共:虚拟 __thiscall soci::details::into_type::~into_type(void)" (??1?$into_type@H@details@soci@@UAE@XZ) 1>main.obj:错误 LNK2001:未解析的外部符号“受保护:虚拟 void __thiscall soci::details::standard_into_type::post_fetch(bool,bool)” (?post_fetch@standard_into_type@details@soci@@MAEX_N0@Z)

我哪里搞砸了?

4

1 回答 1

1

从文档中:

所需的客户端库

SOCI MySQL 后端需要 MySQL 的 libmysqlclient 客户端库。

请注意,SOCI 库本身也依赖于 libdl,因此编译基本客户端程序所需的最小库集是:

-lsoci_core -lsoci_mysql -ldl -lmysqlclient

这一直对我有用。如果要从构建位置链接它们,则需要将带有库路径的 -L 开关传递给编译器。

于 2015-04-01T23:01:17.067 回答