MySQL 库未链接

发布于 2024-11-03 11:14:55 字数 6368 浏览 1 评论 0原文

我使用 cmake 来构建我的项目文件。

这是我的附加链接库:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
..\boost\Debug\boost_lib_thread.lib
..\boost\Debug\boost_lib_system.lib
..\global\Debug\global.lib
C:\Program Files (x86)\OpenSSL-Win32\lib\VC\libeay32MD.lib
C:\Program Files (x86)\OpenSSL-Win32\lib\VC\ssleay32MDd.lib
C:\Program Files (x86)\OpenSSL-Win32\lib\VC\libeay32MDd.lib
C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib

当我尝试编译时出现以下错误:

1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_close@4 referenced in function "public: virtual __thiscall Database::~Database(void)" (??1Database@@UAE@XZ)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_error@4 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_real_connect@32 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_options@12 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_real_escape_string@16 referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Database::EscapeString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?EscapeString@Database@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_errno@4 referenced in function "protected: bool __thiscall Database::_SendQuery(struct DatabaseConnection *,char const *,bool)" (?_SendQuery@Database@@IAE_NPAUDatabaseConnection@@PBD_N@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "protected: bool __thiscall Database::_SendQuery(struct DatabaseConnection *,char const *,bool)" (?_SendQuery@Database@@IAE_NPAUDatabaseConnection@@PBD_N@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_free_result@4 referenced in function "public: __thiscall QueryResult::~QueryResult(void)" (??1QueryResult@@QAE@XZ)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_fetch_row@4 referenced in function "public: bool __thiscall QueryResult::NextRow(void)" (?NextRow@QueryResult@@QAE_NXZ)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_field_count@4 referenced in function "protected: class QueryResult * __thiscall Database::_StoreQueryResult(struct DatabaseConnection *)" (?_StoreQueryResult@Database@@IAEPAVQueryResult@@PAUDatabaseConnection@@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_affected_rows@4 referenced in function "protected: class QueryResult * __thiscall Database::_StoreQueryResult(struct DatabaseConnection *)" (?_StoreQueryResult@Database@@IAEPAVQueryResult@@PAUDatabaseConnection@@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_store_result@4 referenced in function "protected: class QueryResult * __thiscall Database::_StoreQueryResult(struct DatabaseConnection *)" (?_StoreQueryResult@Database@@IAEPAVQueryResult@@PAUDatabaseConnection@@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_server_end@0 referenced in function "public: static void __cdecl Database::CleanupLibs(void)" (?CleanupLibs@Database@@SAXXZ)
1>C:\Users\FreakX\Desktop\FrostCore2\build\source\authserver\Debug\AuthServer.exe : fatal error LNK1120: 14 unresolved externals

I use cmake for building my project files.

this are my additional link libraries:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
..\boost\Debug\boost_lib_thread.lib
..\boost\Debug\boost_lib_system.lib
..\global\Debug\global.lib
C:\Program Files (x86)\OpenSSL-Win32\lib\VC\libeay32MD.lib
C:\Program Files (x86)\OpenSSL-Win32\lib\VC\ssleay32MDd.lib
C:\Program Files (x86)\OpenSSL-Win32\lib\VC\libeay32MDd.lib
C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib

I get following errors when i try to compile:

1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_close@4 referenced in function "public: virtual __thiscall Database::~Database(void)" (??1Database@@UAE@XZ)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_error@4 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_real_connect@32 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_options@12 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "public: bool __thiscall Database::InitDB(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned long,unsigned long)" (?InitDB@Database@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I000KK@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_real_escape_string@16 referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Database::EscapeString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?EscapeString@Database@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_errno@4 referenced in function "protected: bool __thiscall Database::_SendQuery(struct DatabaseConnection *,char const *,bool)" (?_SendQuery@Database@@IAE_NPAUDatabaseConnection@@PBD_N@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "protected: bool __thiscall Database::_SendQuery(struct DatabaseConnection *,char const *,bool)" (?_SendQuery@Database@@IAE_NPAUDatabaseConnection@@PBD_N@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_free_result@4 referenced in function "public: __thiscall QueryResult::~QueryResult(void)" (??1QueryResult@@QAE@XZ)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_fetch_row@4 referenced in function "public: bool __thiscall QueryResult::NextRow(void)" (?NextRow@QueryResult@@QAE_NXZ)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_field_count@4 referenced in function "protected: class QueryResult * __thiscall Database::_StoreQueryResult(struct DatabaseConnection *)" (?_StoreQueryResult@Database@@IAEPAVQueryResult@@PAUDatabaseConnection@@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_affected_rows@4 referenced in function "protected: class QueryResult * __thiscall Database::_StoreQueryResult(struct DatabaseConnection *)" (?_StoreQueryResult@Database@@IAEPAVQueryResult@@PAUDatabaseConnection@@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_store_result@4 referenced in function "protected: class QueryResult * __thiscall Database::_StoreQueryResult(struct DatabaseConnection *)" (?_StoreQueryResult@Database@@IAEPAVQueryResult@@PAUDatabaseConnection@@@Z)
1>global.lib(DatabaseSystem.obj) : error LNK2019: unresolved external symbol _mysql_server_end@0 referenced in function "public: static void __cdecl Database::CleanupLibs(void)" (?CleanupLibs@Database@@SAXXZ)
1>C:\Users\FreakX\Desktop\FrostCore2\build\source\authserver\Debug\AuthServer.exe : fatal error LNK1120: 14 unresolved externals

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏大泽ㄣ 2024-11-10 11:14:55

除了 libmysql 之外,尝试添加 libmysqlpp。这是 C++ API,从链接器错误来看,您似乎正在尝试使用它。

Try adding libmysqlpp in addition to libmysql. This is the C++ API, which from the linker errors you do appear to be trying to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文