Skip to content

bug: Windows MSVC release build fails with unresolved libc symbols #21

Description

@danielsreichenbach

Summary

The Release Binaries workflow fails for x86_64-pc-windows-msvc with linker errors for four libc functions.

Error

From run #22211846804:

error LNK2019: unresolved external symbol gmtime_s referenced in function _ZN5rilua6stdlib2os7os_date...
error LNK2019: unresolved external symbol localtime_s referenced in function _ZN5rilua6stdlib2os7os_date...
error LNK2019: unresolved external symbol fprintf referenced in function _ZN5rilua6stdlib2io7g_write...
error LNK2019: unresolved external symbol fscanf referenced in function _ZN5rilua6stdlib2io6g_read...
fatal error LNK1120: 4 unresolved externals

Affected symbols

Symbol File Function
gmtime_s src/stdlib/os.rs os_date (UTC)
localtime_s src/stdlib/os.rs os_date (local)
fprintf src/stdlib/io.rs g_write
fscanf src/stdlib/io.rs g_read

Cause

The FFI declarations in src/platform.rs reference C runtime functions that require explicit linking on Windows MSVC. The CI test workflow passes because it runs cargo test on Linux, but the release binary workflow cross-compiles with --target x86_64-pc-windows-msvc where the universal C runtime (ucrt) is not linked automatically.

Possible fixes

  1. Add #[link(name = "ucrt")] or #[link(name = "msvcrt")] to the FFI extern blocks on Windows
  2. Use #[cfg_attr(target_env = "msvc", link(name = "ucrt"))] conditionally
  3. Add a build.rs that emits cargo:rustc-link-lib=ucrt on MSVC targets

First observed

Tag v0.1.8, workflow run on 2026-02-20.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions