sudara / pamplejuce

A JUCE audio plugin template. JUCE 7, Catch2, Pluginval, macOS notarization, Azure Trusted Signing, Github Actions
https://melatonin.dev/blog/
MIT License
405 stars 39 forks source link

Always static link to Visual C++ Redistributable Runtime #111

Closed sudara closed 3 months ago

sudara commented 3 months ago

After seeing this forum thread I felt like it was important to move to static linkage for the Windows runtime (and avoid DLL hell).

As of June 2024, JUCE Projucer and CMake both default to dynamic linkage for the microsoft runtime. The reasoning is historical: https://forum.juce.com/t/important-breaking-change-juce-will-now-use-dynamic-linking-for-the-windows-runtime-by-default/25276

The FLS Slots issue was resolved in 2019, but the JUCE default was never updated again: https://blogs.windows.com/windows-insider/2019/01/09/announcing-windows-10-insider-preview-build-18312/

To do dynamic linking right, one has to get every customer to install the latest runtime to ensure your executable will run. Games tend to do this, the UX is pretty unergonomic and awful. I believe you have to actually spawn the second installer for the runtime.

Although static linking creates a bit more duplication and binary bloat, it avoids DLL hell. It's the default for many devs I know, including open source repositories like Surge, so this should be the Pamplejuce (and IMO JUCE) default.

sudara commented 3 months ago

Pre static-linking branch using the developer command prompt:

C:\Program Files\Microsoft Visual Studio\2022\Community>dumpbin /dependents "C:\Program Files\Pamplejuce Company\Pamplejuce Demo\Pamplejuce Demo.exe"
Microsoft (R) COFF/PE Dumper Version 14.40.33811.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file C:\Program Files\Pamplejuce Company\Pamplejuce Demo\Pamplejuce Demo.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    USER32.dll
    GDI32.dll
    SHELL32.dll
    ole32.dll
    OLEAUT32.dll
    COMDLG32.dll
    MSVCP140.dll
    SHLWAPI.dll
    WINMM.dll
    d2d1.dll
    dxgi.dll
    d3d11.dll
    dcomp.dll
    IMM32.dll
    VCRUNTIME140.dll
    VCRUNTIME140_1.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-time-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-utility-l1-1-0.dll
sudara commented 3 months ago

On the static-linking branch:

C:\Program Files\Microsoft Visual Studio\2022\Community>dumpbin /dependents "C:\Program Files\Pamplejuce Company\Pamplejuce Demo\Pamplejuce Demo.exe"
Microsoft (R) COFF/PE Dumper Version 14.40.33811.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file C:\Program Files\Pamplejuce Company\Pamplejuce Demo\Pamplejuce Demo.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    USER32.dll
    GDI32.dll
    SHELL32.dll
    ole32.dll
    OLEAUT32.dll
    COMDLG32.dll
    SHLWAPI.dll
    WINMM.dll
    d2d1.dll
    dxgi.dll
    d3d11.dll
    dcomp.dll
    IMM32.dll