You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在GitHub Actions用cl.exe编译Windows版libuv时遇errno未声明错误

Fixing C2065: 'errno': undeclared identifier When Compiling libuv with cl.exe in GitHub Actions

Looks like you're hitting a common header dependency issue with MSVC's CRT headers. The error stems from corecrt_memcpy_s.h referencing errno without the compiler having already included the header that defines it (<errno.h>). Here's how to fix it:

Solution 1: Force-include <errno.h> in your compile command

MSVC's cl tool has an /include flag that lets you force a header to be included before any source files. Add this to your command to ensure errno is declared early enough:

cl /c /MT -Iinclude -Iinclude\uv -Isrc /include:errno.h -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600 ${{ env.SOURCES }}

Solution 2: Add the required CRT macro definition

In some cases, MSVC hides certain standard definitions behind specific macros. Try adding _CRT_STDIO_INCLUDE_DEPRECATED_IOSTREAMS to your preprocessor definitions to ensure <errno.h> is properly pulled in by dependent headers:

cl /c /MT -Iinclude -Iinclude\uv -Isrc /include:errno.h -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600 -D_CRT_STDIO_INCLUDE_DEPRECATED_IOSTREAMS ${{ env.SOURCES }}

Why removing /MT didn't help

The /MT flag controls whether you link against the static CRT library, but errno is required regardless of static/dynamic linking. Removing it doesn't address the root issue of the missing header inclusion.

Just a quick sanity check: make sure your vcvars64.bat path is correct for your VS 2017 Enterprise installation (which it looks like it is) — this script sets up all the necessary environment variables for MSVC to find system headers correctly.

内容的提问来源于stack exchange,提问作者Bernardo Ramos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:14:11