MySQL C++ 连接器未解析的依赖项 (VS 2015)

MySQL C++ Connector Unresolved Dependencies (VS 2015)

我正在尝试在 Windows / Visual Studio 2015 上编译 MySQL Connector C++。 我根据 official instructions 使用 CMake 生成了项目文件,效果很好。现在,当我尝试编译解决方案时,出现以下链接器错误:

5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_server_init@12 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::library_init(int,char * *,char * *)" (?library_init@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHHPAPAD0@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_server_end@0 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::library_end(void)" (?library_end@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXXZ)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_thread_init@0 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::thread_init(void)" (?thread_init@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXXZ)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_thread_end@0 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::thread_end(void)" (?thread_end@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXXZ)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_num_rows@4 referenced in function "public: virtual unsigned __int64 __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::num_rows(struct st_mysql_res *)" (?num_rows@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAE_KPAUst_mysql_res@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_num_fields@4 referenced in function "public: virtual unsigned int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::num_fields(struct st_mysql_res *)" (?num_fields@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEIPAUst_mysql_res@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_fetch_field_direct@8 referenced in function "public: virtual struct st_mysql_field * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_field_direct(struct st_mysql_res *,unsigned int)" (?fetch_field_direct@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql_field@@PAUst_mysql_res@@I@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_field_count@4 referenced in function "public: virtual unsigned int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::field_count(struct st_mysql *)" (?field_count@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEIPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_affected_rows@4 referenced in function "public: virtual unsigned __int64 __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::affected_rows(struct st_mysql *)" (?affected_rows@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAE_KPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_errno@4 referenced in function "public: virtual unsigned int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::mysql_errno(struct st_mysql *)" (?mysql_errno@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEIPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_error@4 referenced in function "public: virtual char const * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::error(struct st_mysql *)" (?error@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPBDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_sqlstate@4 referenced in function "public: virtual char const * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::sqlstate(struct st_mysql *)" (?sqlstate@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPBDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_warning_count@4 referenced in function "public: virtual unsigned int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::warning_count(struct st_mysql *)" (?warning_count@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEIPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_info@4 referenced in function "public: virtual char const * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::info(struct st_mysql *)" (?info@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPBDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "public: virtual struct st_mysql * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::init(struct st_mysql *)" (?init@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql@@PAU5@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_ssl_set@24 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::ssl_set(struct st_mysql *,char const *,char const *,char const *,char const *,char const *)" (?ssl_set@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql@@PBD1111@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_real_connect@32 referenced in function "public: virtual struct st_mysql * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::real_connect(struct st_mysql *,char const *,char const *,char const *,char const *,unsigned int,char const *,unsigned long)" (?real_connect@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql@@PAU5@PBD111I1K@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::query(struct st_mysql *,char const *)" (?query@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@PBD@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_real_query@12 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::real_query(struct st_mysql *,char const *,unsigned long)" (?real_query@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@PBDK@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_store_result@4 referenced in function "public: virtual struct st_mysql_res * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::store_result(struct st_mysql *)" (?store_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql_res@@PAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_use_result@4 referenced in function "public: virtual struct st_mysql_res * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::use_result(struct st_mysql *)" (?use_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql_res@@PAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_get_character_set_info@8 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::get_character_set_info(struct st_mysql *,void *)" (?get_character_set_info@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXPAUst_mysql@@PAX@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_ping@4 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::ping(struct st_mysql *)" (?ping@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_get_server_info@4 referenced in function "public: virtual char const * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::get_server_info(struct st_mysql *)" (?get_server_info@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPBDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_get_client_version@0 referenced in function "public: virtual unsigned long __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::get_client_version(void)" (?get_client_version@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEKXZ)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_get_server_version@4 referenced in function "public: virtual unsigned long __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::get_server_version(struct st_mysql *)" (?get_server_version@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEKPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_options@12 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::options(struct st_mysql *,enum mysql_option,void const *)" (?options@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@W4mysql_option@@PBX@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_options4@16 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::options(struct st_mysql *,enum mysql_option,void const *,void const *)" (?options@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@W4mysql_option@@PBX2@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_get_option@12 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::get_option(struct st_mysql *,enum mysql_option,void const *)" (?get_option@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@W4mysql_option@@PBX@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_free_result@4 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::free_result(struct st_mysql_res *)" (?free_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXPAUst_mysql_res@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_data_seek@12 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::data_seek(struct st_mysql_res *,unsigned __int64)" (?data_seek@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXPAUst_mysql_res@@_K@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_fetch_row@4 referenced in function "public: virtual char * * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_row(struct st_mysql_res *)" (?fetch_row@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAPADPAUst_mysql_res@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_fetch_lengths@4 referenced in function "public: virtual unsigned long * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_lengths(struct st_mysql_res *)" (?fetch_lengths@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAKPAUst_mysql_res@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_fetch_field@4 referenced in function "public: virtual struct st_mysql_field * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::fetch_field(struct st_mysql_res *)" (?fetch_field@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql_field@@PAUst_mysql_res@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_real_escape_string@16 referenced in function "public: virtual unsigned long __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::real_escape_string(struct st_mysql *,char *,char const *,unsigned long)" (?real_escape_string@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEKPAUst_mysql@@PADPBDK@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_debug@4 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::debug(char const *)" (?debug@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXPBD@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_init@4 referenced in function "public: virtual struct st_mysql_stmt * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_init(struct st_mysql *)" (?stmt_init@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql_stmt@@PAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_prepare@12 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_prepare(struct st_mysql_stmt *,char const *,unsigned long)" (?stmt_prepare@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql_stmt@@PBDK@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_execute@4 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_execute(struct st_mysql_stmt *)" (?stmt_execute@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_fetch@4 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_fetch(struct st_mysql_stmt *)" (?stmt_fetch@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_store_result@4 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_store_result(struct st_mysql_stmt *)" (?stmt_store_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_param_count@4 referenced in function "public: virtual unsigned long __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_param_count(struct st_mysql_stmt *)" (?stmt_param_count@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEKPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_attr_set@12 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_attr_set(struct st_mysql_stmt *,enum enum_stmt_attr_type,void const *)" (?stmt_attr_set@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql_stmt@@W4enum_stmt_attr_type@@PBX@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_bind_param@8 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_bind_param(struct st_mysql_stmt *,struct st_mysql_bind *)" (?stmt_bind_param@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql_stmt@@PAUst_mysql_bind@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_bind_result@8 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_bind_result(struct st_mysql_stmt *,struct st_mysql_bind *)" (?stmt_bind_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql_stmt@@PAUst_mysql_bind@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_close@4 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_close(struct st_mysql_stmt *)" (?stmt_close@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_free_result@4 referenced in function "public: virtual bool __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_free_result(struct st_mysql_stmt *)" (?stmt_free_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAE_NPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_send_long_data@16 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_send_long_data(struct st_mysql_stmt *,unsigned int,char const *,unsigned long)" (?stmt_send_long_data@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql_stmt@@IPBDK@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_result_metadata@4 referenced in function "public: virtual struct st_mysql_res * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_result_metadata(struct st_mysql_stmt *)" (?stmt_result_metadata@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPAUst_mysql_res@@PAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_errno@4 referenced in function "public: virtual unsigned int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_errno(struct st_mysql_stmt *)" (?stmt_errno@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEIPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_error@4 referenced in function "public: virtual char const * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_error(struct st_mysql_stmt *)" (?stmt_error@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPBDPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_sqlstate@4 referenced in function "public: virtual char const * __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_sqlstate(struct st_mysql_stmt *)" (?stmt_sqlstate@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEPBDPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_data_seek@12 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_data_seek(struct st_mysql_stmt *,unsigned __int64)" (?stmt_data_seek@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXPAUst_mysql_stmt@@_K@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_num_rows@4 referenced in function "public: virtual unsigned __int64 __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_num_rows(struct st_mysql_stmt *)" (?stmt_num_rows@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAE_KPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_affected_rows@4 referenced in function "public: virtual unsigned __int64 __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_affected_rows(struct st_mysql_stmt *)" (?stmt_affected_rows@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAE_KPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_field_count@4 referenced in function "public: virtual unsigned int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_field_count(struct st_mysql_stmt *)" (?stmt_field_count@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEIPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_commit@4 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::commit(struct st_mysql *)" (?commit@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_rollback@4 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::rollback(struct st_mysql *)" (?rollback@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_autocommit@8 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::autocommit(struct st_mysql *,char)" (?autocommit@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql@@D@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_more_results@4 referenced in function "public: virtual char __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::more_results(struct st_mysql *)" (?more_results@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEDPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_next_result@4 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::next_result(struct st_mysql *)" (?next_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_stmt_next_result@4 referenced in function "public: virtual int __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::stmt_next_result(struct st_mysql_stmt *)" (?stmt_next_result@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEHPAUst_mysql_stmt@@@Z)
5>mysqlcppconn-static.lib(mysql_client_api.obj) : error LNK2019: unresolved external symbol _mysql_close@4 referenced in function "public: virtual void __thiscall sql::mysql::NativeAPI::LibmysqlStaticProxy::close(struct st_mysql *)" (?close@LibmysqlStaticProxy@NativeAPI@mysql@sql@@UAEXPAUst_mysql@@@Z)

如果你不想数的话:有 64 个。我注意到,我已经安装了 64 位版本的 C++ 连接器源和 32 位版本的 C 连接器,所以我安装了 C 连接器 64 位,链接器错误恰好加倍 (128)。

所以我卸载了两者并安装了两者的 32 位版本,结果 return 出现了您在上面看到的错误。

我知道有很多人提出了很多问题,他们有同样的问题,但我要么找不到可以帮助我的问题,要么 none。

如果你能指出我的解决方案,那就太好了。

感谢您的宝贵时间

"I generated the project file using CMake according to the official instructions, which worked fine."

我假设你的意思是 CMake 成功生成了项目,但项目没有正确编译。

您是否检查过哪些二进制文件当前链接到失败的项目?如果没有,我建议从解决方案资源管理器中右键单击该项目 -> 属性 -> 链接器。

如果 CMake 缓存了包含所需二进制文件的某些目录,请转到 CMake -> 文件选项卡 -> 删除缓存,然后重新生成项目。

我能想到的另一件事是检查包含 MySQL 二进制文件路径的环境变量。如果您的环境变量发生了变化,您可能需要重新运行 CMake,清除其缓存并重新生成项目。

如果您确定正在链接二进制文件,则可能有某些启用静态链接的宏。我不记得 MySQL 连接器是否是这种情况,但这只是我想到的另一件事。

经过几天的搜索和测试,我找到了问题所在。我很惊讶地看到这种情况自 2017 年甚至更早以来一直在发生。

问题:

MySQL 网站上的文档令人困惑、过时且无用。

如果您正在下载最新的mysql-connector-c++-8.0.13-winx64.zip,您会发现库mysqlcppconn-static.lib 这是 64+ MB。您可以在您的项目中使用它,但是,您还需要 .dll,并且它仅在发布版本中内置。

如果你想编译你自己的连接器,只要你有 "right" 命令就可以这样做。您可以构建 x64 的 STATIC DEBUG 版本以在您的应用程序中工作,并且不需要 .dll。

但是,根据发布的 OP,您会遇到上述错误。问题是需要手动linkmysqlclient.lib。在哪里可以找到它?因为在他们的下载页面中他们说:"Windows: The Client Utilities Package is available from the Windows Installer." 这是错误的。没有这样的东西。

你必须做的是去:MySQL Connector/C (Archived Versions)并下载mysql-connector-c-6.1.11-winx64-debug.zip.一旦你有了这个,你就可以在你的项目中 link 这些:

#pragma comment(lib, "mysqlcppconn-static.lib")
#pragma comment(lib, "mysqlclient.lib") // mysql-connector-c-6.1.11-winx64\lib\vs14\debug

并且您的项目将在 Debug x64 和 VS2017 下编译并正常工作(在我的例子中)。

更多问题

注意到我提到的 Oracle 提供的 mysqlcppconn-static.lib 有 64+MB 吗?我之所以这么说,是因为当 you/we 构建我们自己的 mysql 连接器时,库将只有大约 16 MB。

是的,Oracle 以某种方式 link 1 个库中的所有内容。然而它是无用的,因为它是在 Release 中并使用 多线程 DLL (/MD) 构建,所以如果你在调试模式下处理你的应用程序,它不会编译或者你不会能够调试任何东西。

更多问题:

现在我们知道了如何在 x64 和 DEBUG 下构建这个 MySQL 连接器,它仍然只能在 多线程调试 DLL (/MDd) 下工作。所以基本上你不能在 /MT 或 /MTd 下构建 this/your 应用程序。

构建当前 MySQL 连接器(他们称之为 JDBC )的步骤:

  • 下载最新主控: https://github.com/mysql/mysql-connector-cpp
  • 下载最新的 JDBC 分支机构:https://github.com/mysql/mysql-connector-cpp/tree/jdbc
  • mysql-connector-cpp-jdbc中的所有内容复制到 mysql-connector-cpp-master\jdbc
  • 打开 VS 2017 的 x64 本机工具命令提示符并导航到 mysql-connector-cpp-master
  • 运行 这个命令(假设你想要静态调试):

    cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=调试 -DBUILD_STATIC=true -DBUNDLE_DEPENDENCIES=ON -DSTATIC_MSVCRT=OFF -DWITH_JDBC=ON

  • 完成后,通过 mysql-connector-cpp-master\jdbc 中的资源管理器,然后 你会看到 MYSQLCPPCONN.sln

  • 从那里构建解决方案,你会在 mysql-connector-cpp-master\jdbc\driver\Debug

暂时就这些了,我希望我解决这个问题的努力 "mystery" 能帮助到别人。我真诚地希望 Oracle 开发人员能够觉醒并正确创建解决方案和文档,因为我们已经进入 2019 年了。