How to I update my C++ project in Visual Studio 2015 to use the new Universal CRT?

﹥>﹥吖頭↗ 提交于 2019-11-30 12:25:48

问题


After VS2015 updated my project to the new Platform toolset v140, it fails to build due to a linker error : LNK1104 cannot open file 'libucrt.lib'.

It appears this library has been moved around due to the new Universal CRT as mentioned in this article : http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx?PageIndex=2.

While the article does tell me what I should link towards now, it does not provide instructions how.

My Solution generates a .exe and a .dll it uses. I do not know what to do with the matrix the article describes below.

Release DLLs (/MD ): msvcrt.lib vcruntime.lib ucrt.lib

Release Static (/MT ): libcmt.lib libvcruntime.lib libucrt.lib


回答1:


When you convert your project, you need to make sure you update both the includes AND the linker settings to point to the new CRT.

For includes, add the following:

$(UniversalCRT_IncludePath)

For link, add one of the following depending on your target processor:

$(UniversalCRT_LibraryPath_x86)
$(UniversalCRT_LibraryPath_x64)
$(UniversalCRT_LibraryPath_arm)



回答2:


The built-in variable $(LibraryPath) resolves to all the library paths needed to build an application in Visual Studio, including UCRT paths in VS 2015.

Note: you might want to update the include path as well, the portable built-in variable for that is: $(IncludePath).

Or better yet, if you require no library or include path customization, is to use defaults (select <inherit from parent or defaults>).

Note 2: you can adjust the paths for multiple projects and multiple targets at the same time, just select multiple projects, then select "properties".




回答3:


I have downloaded the SDK 10.0.10586.0, which now contains the library libucrt.lib in C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\ucrt\x64. But I cannot get the linker to locate this library; it uses 10240 (the previous installed version).

The macros referred to above, $(LibraryPath) and $(UniversalCRT_LibraryPath_x64), both refer to C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64. I don't know how to change the values for these macros, which presumably is necessary to get the linker to use the proper library.

Windows 7 Pro, 64-bit, Visual Studio 2015 update 1. Linking static libraries, C++ and Intel Fortran project.




回答4:


By default if you compile your project with vs2015, Universal CRT will be in use. (Nothing special needs to be done)

But if you want to statically link (and get rid of ucrt dependency) - read this article:

Visual studio 2015 run-time dependencies or how to get rid of Universal CRT?



来源:https://stackoverflow.com/questions/31527969/how-to-i-update-my-c-project-in-visual-studio-2015-to-use-the-new-universal-cr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!