Visual Studio 项目中的静态 link MySQL X DevAPI

Static link MySQL X DevAPI in Visual Studio Project

我想使用 MySQL X DevApi(C++ 连接器),在按照文档说明完成所有操作后,我仍然无法构建我的项目。

我在项目属性(版本 x64)中所做的:

C/C++ => General => Additional Include directoris => Added C:\Program Files\MySQL\Connector C++ 8.0\include

C/C++ => Preprocessor => Preprocessor Definitions => Added STATIC_CONCPP

C/C++ => Code Generation => Runtime Library => Picked Multi-threaded DLL (/MD)

Linker => General => Additional Library Directories => Added C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14

Linker => Input => Additional Dependiencies => Added mysqlcppconn8-static.lib

因此,我仍然遇到这些错误(我的项目名为 doesItWork):

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol DnsFree  doesItWork  C:\Users\Robert\source\repos\doesItWork\doesItWork\mysqlcppconn8-static.lib(socket_detail.obj)  1   
Error   LNK2001 unresolved external symbol DnsQuery_A   doesItWork  C:\Users\Robert\source\repos\doesItWork\doesItWork\mysqlcppconn8-static.lib(socket_detail.obj)  1   
Error   LNK1120 2 unresolved externals  doesItWork  C:\Users\Robert\source\repos\doesItWork\x64\Release\doesItWork.exe  1   

因为这些来自 socket_detail.obj 我尝试添加 libcrypto.liblibssl.lib 作为文档有时提到的(来自 C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14)但错误仍然出现。

我正在使用 Microsoft Visual Studio Community 2019,我的项目和“Oracle Connector”都用于 x64 Release

现在我的代码看起来像这样(本质上什么都不做):

#include <iostream>
#include <mysqlx/xdevapi.h>
using namespace std;
using namespace mysqlx;

int main()
{
    Session sess("localhost", 33060, "root", "root");
    Schema db = sess.getSchema("mytestdb");
    cout << "hey!" << endl;
}

解决方案是添加 Dnsapi.lib