Skip to content

fix(windows): fix MSVC shared library CRT linking in libghostty-vt#13151

Open
eunos-1128 wants to merge 3 commits into
ghostty-org:mainfrom
eunos-1128:bugfix/libghostty-vt-msvc-ucrt
Open

fix(windows): fix MSVC shared library CRT linking in libghostty-vt#13151
eunos-1128 wants to merge 3 commits into
ghostty-org:mainfrom
eunos-1128:bugfix/libghostty-vt-msvc-ucrt

Conversation

@eunos-1128

Copy link
Copy Markdown

Problem

Building libghostty-vt as a shared library on Windows with MSVC fails because linkLibC()
only links msvcrt.lib, while shared DLL builds also require vcruntime.lib and ucrt.lib.
This blocks downstream projects (e.g., herdr) from building against libghostty-vt on Windows.

Solution

Explicitly link the full MSVC CRT chain for shared library builds:

  • Link libvcruntime
  • Add Windows SDK UCRT library path to linker search directories
  • Link libucrt

Changes

Modified src/build/GhosttyLibVt.zig to:

  1. Detect shared library builds with MSVC ABI
  2. Dynamically resolve Windows SDK path and architecture-specific UCRT directory
  3. Link missing CRT libraries

This change aligns with an existing fix in GhosttyLib.zig.

Verification

✅ Build succeeds on Windows with MSVC

Related

Addresses the Windows/MSVC build issue encountered when packaging herdr for conda-forge:
conda-forge/staged-recipes#34029

@ghostty-vouch

ghostty-vouch Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Hi @eunos-1128, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/ghostty-org/ghostty/blob/main/CONTRIBUTING.md for more details.

@ghostty-vouch ghostty-vouch Bot closed this Jul 2, 2026
Clarified comments regarding Windows DLL requirements and CRT library linking.
@pluiedev

pluiedev commented Jul 3, 2026

Copy link
Copy Markdown
Member

Vouched manually in #13166

@VectorPeak

This comment has been minimized.

@eunos-1128 eunos-1128 changed the title Fix MSVC shared library CRT linking in libghostty-vt fix(windows): Fix MSVC shared library CRT linking in libghostty-vt Jul 3, 2026
@eunos-1128 eunos-1128 changed the title fix(windows): Fix MSVC shared library CRT linking in libghostty-vt fix(build): Fix MSVC shared library CRT linking in libghostty-vt Jul 3, 2026
@eunos-1128 eunos-1128 changed the title fix(build): Fix MSVC shared library CRT linking in libghostty-vt fix(windows): fix MSVC shared library CRT linking in libghostty-vt Jul 5, 2026
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.

4 participants