Visual Studio 2022 include and lib path issue

I recently installed Visual Studio 2022 and wanted to try opengl. First, I tried to compile it with cmake, but the result failed to compile, and I kept reporting an error LINK: fatal error LNK1104: Unable to open the file "ucrtd.lib"

Then I created a new project, imported the glfw package, and planned to compile it. As a result, a lot of errors were reported after compiling, all of which were E1696. The source file crtdbg.h could not be opened.

What was said on the Internet to reinstall the windows 10 sdk, but it didn't work at all. I tried to install VS2019 again, this is no problem, I began to suspect that the system depends on the path, so I opened the include and lib directories of VS2022 and looked at it

Copy the default configuration, which is the configuration containing the directory

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\include
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include
C:\Program Files\Windows Kits\10\Include\10.0.19041.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\Include\um

This is the configuration of the library directory

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\lib\x64
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\lib\x64
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\lib\x64
C:\Program Files\Windows Kits\10\lib\10.0.19041.0\ucrt\x64
C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64

It turns out that the two directories C:\Program Files\Windows Kits\10\Include\10.0.19041.0\ucrt and C:\Program Files\Windows Kits\10\lib\10.0.19041.0\ucrt\x64 do not exist locally at all. , This is the reason, the lib and include directories of ucrt do not exist, where did it go? I searched according to several other directory structures, and found two directories

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt

Pay attention to the distinction, here is actually an extra x86 (and lib case) in the directory, these two are the real installation dependency paths, as for why the default path is the previous one, it is not clear. There may be a problem with the software installation itself, or it may be the cause of my machine. In short, it is a rather pitiful point.

Then the problem is easy to solve, just copy the following two directory files to the above two directories respectively (this is more convenient, because it is very troublesome for VS to change the default dependency path), and to be more precise:

复制include目录
mkdir C:\Program Files\Windows Kits\10\Include\10.0.19041.0\ucrt
copy C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\* C:\Program Files\Windows Kits\10\Include\10.0.19041.0\ucrt
复制lib目录
mkdir C:\Program Files\Windows Kits\10\lib\10.0.19041.0\ucrt
copy C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\* C:\Program Files\Windows Kits\10\lib\10.0.19041.0\ucrt

 This is not a script that can be used, but it just roughly expresses the meaning, first create two directories, and then copy the files to them. Pro test is effective

Guess you like

Origin blog.csdn.net/paserity/article/details/122505648#comments_22427514