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

后端 未结 4 1352
醉梦人生
醉梦人生 2020-12-28 08:23

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 thi

相关标签:
4条回答
  • 2020-12-28 08:59

    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)
    
    0 讨论(0)
  • 2020-12-28 09:05

    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.

    0 讨论(0)
  • 2020-12-28 09:07

    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?

    0 讨论(0)
  • 2020-12-28 09:10

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

    0 讨论(0)
提交回复
热议问题