简体   繁体   中英

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

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

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)

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" .

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM