LNK2022 and LNK2034 linker errors with version 10.0 of the CRT LNK2022 and LNK2034 linker errors with version 10.0 of the CRT windows windows

LNK2022 and LNK2034 linker errors with version 10.0 of the CRT


This is a hard to diagnose problem, the linker errors stink and are poorly documented. There's a post from Stephan Lavavej, the STL maintainer at Microsoft about it in this thread, bottom of the page. I have to say I don't see much of any advice in it, beyond trying to disable iterator debugging in your project settings (_HAS_ITERATOR_DEBUGGING = 0 in the preprocessor definitons).

You do need to consider a code review. It sure looks like you are compiling STL code into managed code. That works in general (minus the linker hassle) but it is really the wrong thing to do. Leave the STL collection classes to your native code, use the BCL collection classes (List<> etc) in your managed code.


In my case what helped was changing the TargetFramework in the .VCXPROJ to :

<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>

But as you've mentioned you need to compile against 3.5 I am not sure what you can do in that case.


for anyone like me that this answer did not ring helpful, a second option is to go to:Project Properties->Configuration Properties->General->Project Defaults->.NET Target Framework Version and set it to v4.0

https://connect.microsoft.com/VisualStudio/feedbackdetail/view/806238/unwarranted-linker-errors-using-stl-filestream-class-in-managed-classes-in-c-11-cli has an obscure answer from Microsoft team that fixed my issue.