gpt4 book ai didi

C++/CLR 托管单元测试有链接器错误

转载 作者:行者123 更新时间:2023-12-01 14:40:43 26 4
gpt4 key购买 nike

当将任何托管类包含到我的托管单元测试时,编译会吐出这些错误:

1>UnitTest.obj : error LNK2020: unresolved token (0A000360) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)
1>UnitTest.obj : error LNK2020: unresolved token (0A000361) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)
1>UnitTest.obj : error LNK2028: unresolved token (0A0003E6) "extern "C" void __cdecl _invalid_parameter(wchar_t const *,wchar_t const *,wchar_t const *,unsigned int,unsigned int)" (?_invalid_parameter@@$$J0YAXPB_W00II@Z) referenced in function "public: void __thiscall std::_Iterator_base12::_Orphan_me(void)" (?_Orphan_me@_Iterator_base12@std@@$$FQAEXXZ)
1>UnitTest.obj : error LNK2019: unresolved external symbol "extern "C" void __cdecl _invalid_parameter(wchar_t const *,wchar_t const *,wchar_t const *,unsigned int,unsigned int)" (?_invalid_parameter@@$$J0YAXPB_W00II@Z) referenced in function "public: void __thiscall std::_Iterator_base12::_Orphan_me(void)" (?_Orphan_me@_Iterator_base12@std@@$$FQAEXXZ)
1>UnitTest.obj : error LNK2001: unresolved external symbol "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)

我正在使用一个 clr 项目并包含一个托管类。删除包含允许测试编译。

最佳答案

要解决这个问题你必须删除

"_DEBUG"

来自中的测试项目

[TestProject] -> Properties -> C/C++ --> Preprocessor --> Preprocessor Definitions

或者你可以改变

"_DEBUG" to "NDEBUG"

关于C++/CLR 托管单元测试有链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49289854/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com