【发布时间】:2012-08-12 13:08:43
【问题描述】:
我在 Visual C++ 2010 环境中有一个未来的命令行程序。我使用了正确构建和安装的 MySQL++ 库。
首先,我在 stdafx.h 中定义了一些全局变量(程序非常简单,所以我基本上使用该文件来满足我所有的头文件需求,并且不使用任何其他头文件。头文件通常具有“#if !defined "... "#endif" 换行。链接器抱怨:
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
虽然在“库目录”属性中包含 MySQL++ 的 LIB 文件夹路径,但配置为 Debug,我在 LIB 文件夹中有以下文件:**mysqlpp_d.dll mysqlpp_d.lib **。
如果有人能帮助我了解我做错了什么,我将不胜感激。
【问题讨论】:
-
谢谢。确实,看起来很像。
标签: visual-c++ linker mysql++