c – 尝试针对旧STD库和Windows SDK进行编译时链接错误

我有一个在VS2005中编译的旧项目(可悲).它必须保留在VS2005中,以便它可以正确链接到另一个具有VS2005 CRT,MFC等的进程.

现在我需要使用旧的VS2005工具集在VS2015中编译这个项目.
我已将项目的VC目录更改为所有STD和Windows SDK标头/库(包括目录,参考目录,库目录,源目录)的旧文件夹.

这个技巧曾经在使用VS2010时工作正常,但在VS2015上我遇到了一些奇怪的链接错误:

1>Project1.obj : error LNK2019: unresolved external symbol "void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M@YGXPAXIIP6EX0@Z@Z) referenced in function "public: virtual void * __thiscall PluginInterface::`vector deleting destructor'(unsigned int)" (??_EPluginInterface@@UAEPAXI@Z)
1>     1>
1>StdAfx.obj : error LNK2001: unresolved external symbol "void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M@YGXPAXIIP6EX0@Z@Z)
1>     1>
1>Project1.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z) referenced in function __unwindfunclet$?getInstance@Project1@@SAPAV1@XZ$0
1>     1>
1>Project1.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete[](void *,unsigned int)" (??_V@YAXPAXI@Z) referenced in function "public: virtual void * __thiscall PluginInterface::`vector deleting destructor'(unsigned int)" (??_EPluginInterface@@UAEPAXI@Z)

为什么要寻找删除器的内部实现?它应该从标题中获取实现吗?为什么它在VS2010而不是VS2015中有效?

我该如何正确解决这个问题?

最佳答案
因此,在阅读了大量重大变更文档后,我发现了一个标志,可以在Placement new和delete下禁止这些新的c 14删除实现here.

添加标志/Zc:sizedDealloc-将删除缺少的运算符delete()实现.
项目属性 – >配置属性 – > C/C++ – >命令行 – > / ZC:sizedDealloc-

you can revert to the old behavior by using the compiler option
/Zc:sizedDealloc-. If you use this option, the two-argument delete
functions don’t exist and won’t cause a conflict with your placement
delete operator.

对于eh向量析构函数迭代器错误我是opened a separate questionanswered it there.

转载注明原文:c – 尝试针对旧STD库和Windows SDK进行编译时链接错误 - 代码日志