sách gpt4 ai đã đi

c++ - std::exception::_Raise 和 std::exception::exception 上的 VC++ 链接器错误

In lại 作者:行者123 更新时间:2023-11-28 08:34:20 34 4
mua khóa gpt4 Nike

我正在使用 Visual C++ 2005 Express Edition 并遇到以下链接器错误:

19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "protected: static void __cdecl std::vector >::_Xlen(void)" (?_Xlen@?$vector@Vmytype@@V?$allocator@Vmytype@@@std@@@std@@KAXXZ)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ)
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string,class std::allocator > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)

我在生成的代码中关闭了异常,并且在包含 vector 头文件之前使用:

#define _HAS_EXCEPTIONS 0

一些谷歌搜索结果出现了一些东西,但没有“啊哈!”对我有用的解决方案。

biên tập:

如前所述,“_HAS_EXCEPTIONS 0”本身不会关闭异常。它所做的是,至少在 vector 头文件中,是在异常对象上调用 _Raise 而不是调用 C++“throw”。在我的例子中,它无法链接到异常对象的 _Raise 函数,因为我没有包含正确的库。但是,该库是什么并不明显。

1 Câu trả lời

添加这一行:

#define _STATIC_CPPLIB

在包含 vector header 之前似乎可以解决问题。

关于c++ - std::exception::_Raise 和 std::exception::exception 上的 VC++ 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/249607/

34 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com