15
votes

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

4
The blog post looks pretty clear to me. It gives the new libs and the paths to find them. What steps did you do when you "updated" your project? - Ryan Bemrose
I selected my solution from the Solution Explorer, and 're-armed', I believe was the term, which remapped each project to the new compiler. I then added $(UniversalCRT_IncludePath) to Additional Include Directives in their configuration properties. - Jesse Meyer
Did you also add $(UniversalCRT_LibraryPath_*) (depending on your target processor) to the link settings? - Ryan Bemrose
I had not, and that resolved the issue. Thanks! If you submit that as an answer I'll accept it. - Jesse Meyer
Are you using Visual Studio 2015 RC or RTM? We made some tweaks in RTM to the targets to try to reduce the impact of the directories change. If you're using Visual Studio 2015 RTM, would you be willing to share [1] what your IncludePath and LibraryPath are set to in your project or [2] could you share the entire project file with us? We're interested in understanding what kinds of project files are not picking up the new default settings. (You may e-mail me at [email protected], if you'd like.) - James McNellis

4 Answers

11
votes

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)
3
votes

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
votes

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.

2
votes

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?