如何修复在 R 中加载“wk”包时出错?

How to fix Error loading 'wk' package in R?

提问人:MSMagona 提问时间:10/9/2023 最后编辑:jay.sfMSMagona 更新时间:10/10/2023 访问量:49

问:

尝试在 R 中加载“wk”包时收到以下错误消息:

> install.packages("wk")
Retrieving 'https://cloud.r-project.org/src/contrib/wk_0.8.0.tar.gz' ...
    OK [file is up to date]
Installing wk [0.8.0] ...
    FAILED
Error installing package 'wk':
==============================

* installing *source* package ‘wk’ ...
** package ‘wk’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -I"/opt/R/4.1.3/lib64/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include   -fpic  -g -O2  -c bbox-handler.c -o bbox-handler.o
bbox-handler.c: In function ‘wk_bbox_handler_realloc_result’:
bbox-handler.c:44:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < 4; i ++) {
     ^
bbox-handler.c:44:5: note: use option -std=c99 or -std=gnu99 to compile your code
bbox-handler.c: In function ‘wk_bbox_handler_append’:
bbox-handler.c:65:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
         for (int i = 0; i < 4; i++) {
         ^
bbox-handler.c: In function ‘wk_c_bbox_handler_new’:
bbox-handler.c:173:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < 4; i++) {
     ^
bbox-handler.c: In function ‘wk_envelope_handler_vector_start’:
bbox-handler.c:201:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < 4; i++) {
     ^
bbox-handler.c: In function ‘wk_c_envelope_handler_new’:
bbox-handler.c:308:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (int i = 0; i < 4; i++) {
     ^
make: *** [bbox-handler.o] Error 1
ERROR: compilation failed for package ‘wk’
* removing ‘/home/mmagona/renv/staging/2/wk’
Error: install of package 'wk' failed [error code 1]

找不到有关此错误的大量信息,我需要它阻止我安装“sf”包。任何帮助表示赞赏。

我正在使用 R 版本 4.1.3

r 处理 编译器错误

评论

0赞 MrFlick 10/9/2023
你是在跑步还是.这真的是你看到的完整输出吗?通常,输出前面有更详细的错误消息。由于运行的是较旧版本的 R,因此需要设置计算机来编译包,因为通常预编译包仅适用于当前版本的 R。您使用的是 Mac、Windows 还是 Linux 计算机?library(wk)install.packages("wk")
0赞 MSMagona 10/9/2023
@MrFlick 我已经更新了完整的错误消息。我正在使用 Windows。所以你是说这只是更新我的 R 版本的情况?
1赞 margusl 10/10/2023
从路径(即 & ) 它看起来不像 Windows。RStudio Server / Posit Workbench ?/opt/R/4.1.3//home/mmagona/renv/staging/2/wk
0赞 MSMagona 10/10/2023
@margusl 对不起,是的,这是 Linux

答: 暂无答案