我在Visual C++2010环境中有一个未来的命令行程序。我使用了MySQL++库,它是正确构建和安装的。
首先,我在stdafx.h中定义了一些全局变量(程序非常简单,所以我基本上使用该文件来满足我的所有头文件需求,而不使用任何其他头文件。头文件通常有“#if!defined”…“#endif”包装。Linker抱怨道:
Error 2 error LNK2005: "__int64 last_local_time" (?last_local_time@@3_JA) already defined in coreprocessing.obj C:\Tsukasa\ilya\DataImporter\DataImporter\stdafx.obj
Error 3 error LNK2005: "bool debug" (?debug@@3_NA) already defined in coreprocessing.obj C:\Tsukasa\ilya\DataImporter\DataImporter\stdafx.obj
Error 4 error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > user" (?user@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in coreprocessing.obj C:\Tsukasa\ilya\DataImporter\DataImporter\stdafx.obj
Error 5 error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > server" (?server@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in coreprocessing.obj C:\Tsukasa\ilya\DataImporter\DataImporter\stdafx.obj
其他链接器错误与Mysql++库有关。
Error 9 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall mysqlpp::Query::`vbase destructor'(void)" (__imp_??_DQuery@mysqlpp@@QAEXXZ) referenced in function "class mysqlpp::Query * __cdecl connectToDb(void)" (?connectToDb@@YAPAVQuery@mysqlpp@@XZ) C:\Tsukasa\ilya\DataImporter\DataImporter\coreprocessing.obj
Error 10 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlpp::DateTime::operator __int64(void)const " (__imp_??BDateTime@mysqlpp@@QBE_JXZ) referenced in function "class mysqlpp::Query * __cdecl connectToDb(void)" (?connectToDb@@YAPAVQuery@mysqlpp@@XZ) C:\Tsukasa\ilya\DataImporter\DataImporter\coreprocessing.obj
而在Properties中,“Library Directories”包括MySQL++的LIB文件夹的路径,配置为Debug,我在LIB文件夹中有以下文件:**mysqlpp_d.dll mysqlpp_d.LIB**。
如果有人能帮助我了解我做错了什么,我将不胜感激。