我使用Visual C++ 2005 Express版本,并得到下面的连接错误:VC++上的std ::例外链接错误:: _加薪和std ::例外::例外
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " ([email protected]@[email protected]@QBEXXZ) referenced in function "protected: static void __cdecl std::vector<class mytype,class std::allocator<class mytype> >::_Xlen(void)" ([email protected][email protected]@@[email protected]@@@[email protected]@@[email protected]@KAXXZ)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " ([email protected]@[email protected]@QBEXXZ)
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" ([email protected]@@[email protected]@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" ([email protected]@@[email protected]@Z)
我关掉例外产生代码,我使用包括矢量头文件之前:
#define _HAS_EXCEPTIONS 0
一些谷歌搜索结果打开了一些东西,但没有“啊哈!”为我工作的解决方案。
编辑:
正如所指出的 “_HAS_EXCEPTIONS 0” 不会关闭异常,本身。它至少在矢量头文件中所做的是在异常对象上调用_Raise,而不是调用C++“throw”。在我的情况下,它不能链接到异常对象的_Raise函数,因为我没有包含正确的库。但是,该图书馆的内容并不明显。