fix(build): link the MSVC runtime statically #72
No reviewers
Labels
No labels
accessibility
bug
ci
docs
documentation
duplicate
enhancement
fixes issue
good first issue
help wanted
invalid
library request
libs
needs rebase
question
relinker
stale
tools
unblocks title
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Dark3581--AnyBox!72
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/72/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Dark3581 on GitHub · 2026-11-23 05:21 UTC · original
Dark3581:fix/msvc-static-runtime→main· +2 −1 · 2 files · 1 commits · merged 2026-11-23 05:23 UTCWhat
MSVC builds linked AnyBox's libraries against the dynamic C and C++ runtime (
MSVCP140.dll,VCRUNTIME140.dlland theapi-ms-win-crt-*sets).anybox_static_runtimeonly made MinGW static. A relinked title's folder holds the title's own console builds ofmsvcp140.dllandvcruntime140.dll, so MSVC-built AnyBox libraries loaded those and could crash in them.Found while testing #71: with the MSVC-built libraries, a bundled GDK module's
HCInitializedied with an access violation reading address 0 atmsvcp140.dll+0x12f70, in the package's ownmsvcp140.dll. The MinGW-built libraries never touch it.set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")in the rootCMakeLists.txtselects the static runtime for every target. It has to be global so the static libraries linked into the DLLs use the same runtime. MinGW builds are unchanged. ARCHITECTURE now says both toolchains link the runtime statically, and why it matters for titles.Tested
Windows 10, MSVC 2022 (fresh build tree) and MinGW (GCC).
ab_runtime.dllnow imports onlyKERNEL32.dll, andab_xgameruntime.dllandab_d3d12_x.dllimport onlyab_runtime.dllandKERNEL32.dll. Before, they importedMSVCP140,VCRUNTIME140,VCRUNTIME140_1and nineapi-ms-win-crt-*sets.ctest: 77 of 77, the full suite.HCInitialize(the #71 harness) now returnsS_OKwith the MSVC-built libraries too, instead of crashing.ab_gameinput, which needsgameinput.lib, which this machine doesn't have. MinGWctest: 77 of 77.python tools/check_conventions.py: ok.Checklist
main; no other open PR implements the same functionspython tools/check_conventions.pypasses (no comments in code, one declaration per export, Conventional Commit subjects)AbxNotImplemented/AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragmentdocs/dev/debt/changes/<branch>.mdCMAKE_MSVC_RUNTIME_LIBRARY)