MySQL C++ Connector Unresolved Dependencies (VS 20

2019-07-11 10:47发布

问题:

I'm trying to compile MySQL Connector C++ on Windows / Visual Studio 2015. I generated the project file using CMake according to the official instructions, which worked fine. Now when I try to compile the solution,I get the following linker errors:

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)

In case you dont want to count: Theres 64 of them. I noticed, that I had installed the 64bit Version of the C++ Connector Source and the 32 bit Version of the C Connector, so I installed the C Connector 64bits and the linker errors exactly doubled (128).

So I deinstalled both and installed the 32 bit version of both, only to return to the errors you see above.

I know there are a bunch of questions out there by people, who have the same problem, but I either was not able to find one that could help me or there is none.

If you can point me towards a fix, that'd be great.

Thanks for your time

回答1:

After days of searching and testing, I have found the problem. I am surprised to see that this is going on since 2017 or even earlier.

The Problem:

Documentation on the MySQL website is confusing, outdated and useless.

If you are downloading the latest mysql-connector-c++-8.0.13-winx64.zip, you will find the library mysqlcppconn-static.lib which is 64+ MB. You can use this in your project BUT, you will need the .dll as well, and this is built in Release version only.

If you want to compile your own connector, you can do so if you have the "right" commands only. You can build STATIC DEBUG versions of x64 to work in your application and no .dll is required.

However you will encounter the above error as per the OP posted. The problem is that you need to manually link mysqlclient.lib. Where to find it ? Because in their downloads page they say: "Windows: The Client Utilities Package is available from the Windows Installer." which is false. There is no such thing.

What you must do is go to: MySQL Connector/C (Archived Versions) and download mysql-connector-c-6.1.11-winx64-debug.zip. Once you have this, you can just link these in your project:

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

And your project will compile and work fine under Debug x64 and VS2017 (in my case).

More Problems:

Noticed where I mentioned that the mysqlcppconn-static.lib provided by Oracle has 64+MB ? The reason why I said that is because when you/we build our own mysql connector, the library will have around 16 MB only.

Yes, Oracle somehow link everything in 1 lib. However it's useless because it's in Release and build with Multi-threaded DLL (/MD), so if you are working on your application in Debug mode it will not compile OR you won't be able to debug anything.

Even More Problems:

Now we I found out how to build this MySQL Connector under x64 and DEBUG, it's still only working under Multi-threaded Debug DLL (/MDd). So basically you cannot build this/your app under /MT or /MTd.

Steps to build current MySQL Connector ( JDBC as they call it ):

  • Download the latest master: https://github.com/mysql/mysql-connector-cpp
  • Download the latest JDBC branch: https://github.com/mysql/mysql-connector-cpp/tree/jdbc
  • Copy all contents from mysql-connector-cpp-jdbc to mysql-connector-cpp-master\jdbc
  • Open up x64 Native Tools Command Prompt for VS 2017 and navigate into mysql-connector-cpp-master
  • Run this command ( assuming you want the STATIC DEBUG ):

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

  • Once done, go via explorer in mysql-connector-cpp-master\jdbc and you will see MYSQLCPPCONN.sln

  • From there just build the solution, and you will find the lib in mysql-connector-cpp-master\jdbc\driver\Debug

That would be all for now, I hope my efforts to solve this "mystery" will help someone. And I sincerely hope that Oracle developers will wake up and create solutions properly and documentation because we are in 2019.



回答2:

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

I assume you meant CMake successfully generated the project but the project doesn't compile correctly.

Have you checked which binaries are currently linked against the failing project? If not, I suggest right clicking on the project from the solution explorer -> Properties -> Linker.

In case CMake cached certain directories that contain the required binaries, go to CMake -> File tab -> Delete cache, and regenerate the project.

One more thing I can think of is checking the environment variables that contain the MySQL binaries path. If something has changed to you environment variables, you might need to rerun CMake, clear its cache and regenerate the project.

If you are certain the binaries are being linked, there might be certain macros that enable static linking. I cannot remember if it is the case with MySQL connector, but it's just another thing that came to mind.