Debug/release

Hello. Using my 2d engine, I participated in an event which has been hosted on Itch.io - a cool place where people share games and apps. At first, I have uploaded my projects and compiled them in Debug mode (under Visual Studio). As I expected, some players said that games required libraries that they did not own (MSVCP140D.dll, VCRUNTIME140D.dll and VCRUNTIME140_1D.dll). It's not really relevant...
So I uploaded another package, but with games compiled as Release app. Then the Itch.io launcher automatically has downloaded the VC redistributable library. This is now my question. When we share a project as Release app, is there something which automatically starts (if it does not exist on the PC) a download for this VC redistributable library?
If we talk about "normal" Desktop applications, not "Microsoft Store" crap, then: No!

You have to take care of installing the Visual C++ Runtime, and maybe other 3rd-party dependencies, that are needed to run your application, on the user's machine. Microsoft offers "Redistributable" packages, which you can ship to the end-user alongside with your application, for exactly that purpose:

https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

On Windows, applications are usually distributed as an installer (setup.exe). So, the Visual C++ Runtime can simply be included in the application's installer. Note that you can invoke the Visual C++ Runtime installer from your "main" installer in a way that it runs in the background and requires no user interaction.

When games are installed through a "launcher" application, such as Steam or Epic Launcher, things are a bit different. There will be some kind of "first run" setup procedure, when you start the game for the first time. During this "first run" setup procedure, the required dependencies, e.g. Visual C++ Runtime or DirectX Runtime, are installed on the local machine. This all is handled by the "launcher" application, not by the game itself!

(Take care: The "debug" version of the Visual C++ Runtime is not redistributable)

________


For example, if you build your installer with NSIS, then you can include (embed) the Visual C++ Runtime installer in your "main" installer, and automatically invoke it during the installation process, like this:
1
2
3
4
5
6
Section "Visual Studio Runtime"
  SetOutPath "$INSTDIR"
  File "redist\msvc\vcredist_x86.exe"
  ExecWait '"$INSTDIR\vcredist_x86.exe" /install /quiet'
  Delete "$INSTDIR\vcredist_x86.exe"
SectionEnd

This will extract vcredist_x86.exe to the installation directory, invoke it with the required arguments, wait for the sub-process (Visual C++ Runtime installer) to finish, and finally delete vcredist_x86.exe.

________

BTW: I much recommend to use a tool like Dependencies to figure out which dependencies your application actually has. Any dependencies, which are not standard Windows system DLLs, must be redistributed!

https://github.com/lucasg/Dependencies#readme
Last edited on
Thank you for your large explanation. I understand that Itch.io launcher works like Steam or Epic Launcher. For this reason, I noticed this "first run" process - then the launcher has downloaded the VC redistributable. Maybe it could be better to create some installer for my projects with all dependencies required. I will take a look at the NSIS application. Thank you for your help. I wish you the best ++
Last edited on
Maybe it could be better to create some installer for my projects with all dependencies required.

Yeah, building a fully self-contained installer is the usual way to go.

...unless you are planning to distribute your game through a service like Steam or Itch.io. As mentioned before, those have their own way of handling the "setup" process. The details probably are different for each service! I assume they have some sort guidelines for developers on how to "prepare" their applications.
Last edited on
In the VC project settings there is an option to link the runtime statically. If you do so you don't need to worry about the runtime dlls.
In the VC project settings there is an option to link the runtime statically. If you do so you don't need to worry about the runtime dlls.

Great. It seems to me that it's probably the best solution ++
You can set the project to have the runtime statically linked in the project's options: Configuration Properties -> C/C++ -> Code Generation -> Runtime Library option.

You should set the option for both the debug and release versions with the Platform option set to All Platforms so the app is statically linked for x86 and x64.

This has to be set for every new project.

It is possible to make it a default, follow the directions here:
https://cplusplus.com/forum/lounge/271176/

Fair Warning, a statically links app can be a source or HUGE BLOAT, depending on which libraries are linked.
File size probably is not that much of an issue nowadays.

An actual downside of using the "static" VC Runtime is that your program will always use the exact version of the VC Runtime that it was built with, so it will not get any security patches or bugfixes that have been applied to the "shared" (DLL) version of the VC Runtime in the "System32" directory, e.g. via Windows Update.

Also, if you link the VC Runtime statically to your "main" EXE file, then all dependencies should be linked statically. Combining an EXE file that uses the "static" VC Runtime with other "shared" libraries (DLL files) is asking for trouble! That is because the "main" EXE file and the DLL file will end up using different/separate instances of the VC Runtime — the "main" EXE file has its own "static" copy the VC Runtime, whereas the DLL probably is linked against the "shared" VC Runtime (DLL). This can cause all kinds of oddities...

(sometimes you have to use a 3rd-party library that simply isn't available as "static" library, only as DLL)
Last edited on
Topic archived. No new replies allowed.