VS2022 vs ptrust.cpp

J Slade 1 Reputation point
2024-11-21T14:22:28.62+00:00

While attempting a C++ compile in VS2022 the following error is raised: LNK1104 cannot open file 'msvcurt.lib'

A search for this file in the VS2022 file structure results in 'file not found'.

Searching by file contents results in this file being identified: ptrust.cpp (found in folder C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.43.34604\crt\src\vcruntime )

ptrust.cpp contains these lines:

#define _PARTIAL_TRUST_OBJ  
#include "mstartup.cpp"  
#if defined (_M_CEE_MIXED)  
#ifdef _DEBUG  
#pragma comment(linker, "/nodefaultlib:msvcmrtd.lib")  
#pragma comment(lib, "msvcrtd.lib")  
#else  /* _DEBUG */  
#pragma comment(linker, "/nodefaultlib:msvcmrt.lib")  
#pragma comment(lib, "msvcrt.lib")  
#endif  /* _DEBUG */  
#else  /* defined (_M_CEE_MIXED) */  
#ifdef _DEBUG  
#pragma comment(linker, "/nodefaultlib:msvcurtd.lib")  
#pragma comment(lib, "msvcrtd.lib")  
#else  /* _DEBUG */  
#pragma comment(linker, "/nodefaultlib:msvcurt.lib")  
#pragma comment(lib, "msvcrt.lib")  
#endif  /* _DEBUG */  
#endif  /* defined (_M_CEE_MIXED) */

What is of concern is that references to msvcurt.lib and msvcurtd.lib are included in this version of VS2022 when they're not included in this install and have been deprecated since 2023 - as per: https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170

Why are references to these deprecated libraries still included in the latest VS2022 install?

How does one resolve this error?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,256 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,783 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.