我使用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
答案 0 :(得分:0)
除了libmysql之外,尝试添加libmysqlpp。这是C ++ API,它来自您尝试使用的链接器错误。