Skip to content

Link the C runtime statically - #7

Closed
Gvo87 wants to merge 1 commit into
x86-arm64-buildsfrom
static-crt
Closed

Gvo87 wants to merge 1 commit into
x86-arm64-buildsfrom
static-crt

Conversation

@Gvo87

@Gvo87 Gvo87 commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Stacked on #6. The base is x86-arm64-builds, so this diff shows only the CRT change. GitHub retargets it to main when #6 merges and its branch is deleted.

Why

LLMAssistant.dll linked the C runtime dynamically (/MD). It imported MSVCP140.dll, VCRUNTIME140.dll (and VCRUNTIME140_1.dll on x64) and the api-ms-win-crt-* DLLs. So Notepad++ could only load the plugin where the VC++ Redistributable for that same architecture was installed. Otherwise Notepad++ reports that the plugin can't be loaded. The redistributable is more likely to be missing for the new 32-bit and ARM64 users. Also, CI builds the ARM64 DLL with v145, so with /MD it would need the redistributable at version 14.50 or later.

Change

  • LLMAssistant.vcxproj: RuntimeLibrary is MultiThreaded (/MT) for Release and MultiThreadedDebug (/MTd) for Debug, on every platform. This is what the Notepad++ plugin template does. The plugin never hands CRT-allocated memory to Notepad++ to free (it returns pointers to static data), so a private CRT is safe.
  • README.md: one line in the build notes saying the DLL needs no Visual C++ Redistributable.
  • The CMake Catch2 test build is unchanged.

Local verification (VS 2026, v145)

x64 Release x86 (Win32) Release
Size before (/MD) 104,448 bytes 95,744 bytes
Size after (/MT) 318,976 bytes 268,800 bytes
Imports after (dumpbin /dependents) WININET, KERNEL32, USER32, GDI32, ADVAPI32 WININET, KERNEL32, USER32, GDI32, ADVAPI32

Other checks:

  • build.bat and build.bat x86 passed /MT to cl.exe and built with 0 compiler or linker warnings. Debug|x64 and Debug|Win32 (/MTd) also build with 0 warnings and import only the same five system DLLs.
  • make-release-zip.ps1 -Platform x64 and -Platform x86 pass the machine type, version (1.1.0.0) and export checks.
  • Each Release DLL was loaded with LoadLibrary in a process of its own bitness (64-bit pwsh, and 32-bit Windows PowerShell). getName returned "LLM Assistant", isUnicode returned 1, and getFuncsArray reported 8 items.
  • ARM64 isn't built locally because the ARM64 tools aren't installed. CI builds it and runs the same packaging checks.
  • Not tested: running the plugin inside Notepad++ on a machine without the VC++ Redistributable.

🤖 Generated with Claude Code

The DLL linked the CRT dynamically (/MD), so Notepad++ could only load it
where the VC++ Redistributable for the same architecture was installed.
That's more likely to be missing for 32-bit and ARM64 users, and the ARM64
DLL is built with v145, so it needs version 14.50 or later. Use
/MT and /MTd, as the Notepad++ plugin template does. The DLL now imports
only Windows system DLLs. Release grows from 102 to 312 KB (x64) and
from 94 to 263 KB (x86).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gvo87

Gvo87 commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

Closing: this commit (12457f4, static CRT) is already on main. It was included in #8 and shipped in v1.2. This PR stayed open only because its base was x86-arm64-builds.

@Gvo87 Gvo87 closed this Oct 16, 2026
@Gvo87
Gvo87 deleted the static-crt branch October 16, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant