Msvc 2015 Universal Crt for App-Local Deployment

MSVC 2015 Universal CRT for app-local deployment

This blog post under Distributing Software that uses the Universal CRT section describes all the cases in detail, with a big red update notice concerning app-local deployment:

Updated September 11, 2015: App-local deployment of the Universal CRT is supported. To obtain the binaries for app-local deployment, install the Windows Software Development Kit (SDK) for Windows 10. The binaries will be installed to C:\Program Files (x86)\Windows Kits\10\Redist\ucrt. You will need to copy all of the DLLs with your app (note that the set of DLLs are necessary is different on different versions of Windows, so you must include all of the DLLs in order for your program to run on all supported versions of Windows)

Running a Visual Studio 2015 C++ Executable Without Installing the Visual C++ Redistributable Packages

This was surprisingly not closed as a duplicate. And I hate leaving open questions unanswered. So I'll answer it myself by saying that codestation's comment links to this question which links to this article which describes how to do this in the section that starts with bold red text.

You shouldn't upvote this. Upvote the answer in the linked question.

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

(Updated 11.10.2016).

It's possible to get rid of universal CRT by linking it statically, I'll get to it later on, but let's take
a look if you continue to use universal CRT as such.

According to article https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/ -
it's possible to launch your application using universal crt dll distributables from following folder:
C:\Program Files (x86)\Windows Kits\10\Redist\ucrt

There are 41 files totally in list with 1.8 Mb size in total. (example for 64-bit platform)

Of course it's not enough, you will need additionally vcruntime140.dll & msvcp140.dll coming from following folder:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT

So after that you will ship totally 43 additional dll's besides your application.

It's also possible to statically compile ucrt library inside your application after which you will not need 43 dll's -
but whether static link will for after linking or not - depends on your application - how many dll's and which api's are in use.
Generally after ucrt gets linked into two different dll's they don't necessarily share same globals with each other - which can results in errors.

You need to link against vcruntime.lib / msvcrt.lib, but it's not sufficient - there are extra _VCRTIMP= and _ACRTIMP=
defines which needs to be disabled from pulling functions from ucrt.

If you're using premake5 you can configure your project like this:

defines { "_VCRTIMP="}
linkoptions { "/nodefaultlib:vcruntime.lib" }
links { "libvcruntime.lib" }

followed by:

defines { "_ACRTIMP="}
linkoptions { "/nodefaultlib:msvcrt.lib" }
links { "libcmt.lib" }

Defines are not documented by Microsoft - so it's possible that it's subject to change in future.

Besides your own projects, you will need to re-compile all static libraries which are in use in your projects.

As for boost libraries - I've managed to compile boost as well, using b2.exe boostrapper

boost>call b2 threading=multi toolset=msvc-14.0 address-model=64 --stagedir=release_64bit --build-dir=intermediate_64but release link=static,shared --with-atomic --with-thread --with-date_time --with-filesystem define=_VCRTIMP= define=_ACRTIMP=

When troubleshooting linking problems - notice that unresolved __imp* function names from because of dllimport keyword usage -
and if you link against libvcruntime.lib, you should not have any __imp* references.

How to distribute VC redist with an MSI when using Visual Studio 2015?

If you use WiX, you could switch to Burn and run the VC Redist packages as part of the setup.

The article you referenced also says that app-local deployment of the Dlls is supported, so you could install the appropriate Dlls without needing redist.

I would use Burn to install the official redist - it's the only way that Mocrosoft can service those Dlls if there are issues. If you use app-local or your own copies of the Dlls you may need to ship patches or upgrades if there are security issues in those Dlls.



Related Topics



Leave a reply



Submit