Windows 11下安装R包httpuv遇uv.h缺失错误求助
安装R包
httpuv时出现uv.h: No such file or directory错误的解决办法 问题背景
在Windows 11设备上执行install.packages("httpuv")安装R包httpuv时,出现编译错误,提示找不到uv.h文件。
核心错误信息
thread.h:4:10: fatal error: uv.h: No such file or directory 4 | #include <uv.h> | ^~~~~~ compilation terminated. make: *** [C:/PROGRA~1/R/R-45~1.0/etc/x64/Makeconf:296: callbackqueue.o] Error 1 ERROR: compilation failed for package 'httpuv'
完整控制台输出
> install.packages("httpuv") There is a binary version available but the source version is later: binary source needs_compilation httpuv 1.6.15 1.6.16 TRUE installing the source package ‘httpuv’ trying URL 'http://cran.rstudio.com/src/contrib/httpuv_1.6.16.tar.gz' Content type 'application/x-gzip' length 1890033 bytes (1.8 MB) downloaded 1.8 MB * installing *source* package 'httpuv' ... ** this is package 'httpuv' version '1.6.16' ** package 'httpuv' successfully unpacked and MD5 sums checked ** using staged installation ********************************************** WARNING: this package has a configure script It probably needs manual configuration ********************************************** ** libs make: pkg-config: No such file or directory using C compiler: 'gcc.exe (x86_64-posix-seh-rev2, Built by MinGW-Builds project) 14.2.0' using C++ compiler: 'G__~1.EXE (x86_64-posix-seh-rev2, Built by MinGW-Builds project) 14.2.0' make: pkg-config: No such file or directory g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-45~1.0/include" -DNDEBUG -D_WIN32_WINNT=0x0600 -DSTRICT_R_HEADERS -I'C:/Program Files/R/R-4.5.0/library/later/include' -I'C:/Program Files/R/R-4.5.0/library/Rcpp/include' -I"c:/rtools45/x86_64-w64-mingw32.static.posix/include" -DSTRICT_R_HEADERS -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-45~1.0/include" -DNDEBUG -D_WIN32_WINNT=0x0600 -DSTRICT_R_HEADERS -I'C:/Program Files/R/R-4.5.0/library/later/include' -I'C:/Program Files/R/R-4.5.0/library/Rcpp/include' -I"c:/rtools45/x86_64-w64-mingw32.static.posix/include" -DSTRICT_R_HEADERS -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c callback.cpp -o callback.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-45~1.0/include" -DNDEBUG -D_WIN32_WINNT=0x0600 -DSTRICT_R_HEADERS -I'C:/Program Files/R/R-4.5.0/library/later/include' -I'C:/Program Files/R/R-4.5.0/library/Rcpp/include' -I"c:/rtools45/x86_64-w64-mingw32.static.posix/include" -DSTRICT_R_HEADERS -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c callbackqueue.cpp -o callbackqueue.o In file included from tqueue.h:7, from callbackqueue.h:4, from callbackqueue.cpp:2: thread.h:4:10: fatal error: uv.h: No such file or directory 4 | #include <uv.h> | ^~~~~~ compilation terminated. make: *** [C:/PROGRA~1/R/R-45~1.0/etc/x64/Makeconf:296: callbackqueue.o] Error 1 ERROR: compilation failed for package 'httpuv' * removing 'C:/Program Files/R/R-4.5.0/library/httpuv' * restoring previous 'C:/Program Files/R/R-4.5.0/library/httpuv' Warning in install.packages : installation of package ‘httpuv’ had non-zero exit status
会话信息
R version 4.5.0 (2025-04-11 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 26100) Matrix products: default LAPACK version 3.12.1 locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C LC_TIME=English_United States.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.5.0 tools_4.5.0 rstudioapi_0.17.1
已安装环境信息
已安装Rtools,执行Sys.which("make")输出:
> Sys.which("make") make "C:\\rtools44\\usr\\bin\\make.exe"
解决建议
- 优先安装二进制版本:控制台提示有可用的二进制版本(1.6.15),无需编译。执行以下命令强制安装:
install.packages("httpuv", type = "binary") - 匹配Rtools版本:当前使用R 4.5.0,对应Rtools版本应为Rtools45,但当前使用的是Rtools44,版本不匹配导致依赖缺失。卸载Rtools44,安装Rtools45,安装时勾选"Add Rtools to system PATH"选项。
- 修复pkg-config缺失:错误提示
pkg-config: No such file or directory,Rtools45包含该工具,安装正确版本后会自动加入系统路径。 - 手动安装libuv依赖(源码安装需求):若必须安装源码版,先通过Rtools的pacman工具安装libuv:
pacman -S mingw-w64-x86_64-libuv,再重新执行源码安装命令。
内容的提问来源于stack exchange,提问作者Nikos
相关产品推荐
相关产品推荐

