在R中安装data.table库:zlib.h没有这样的文件或目录

问题描述 投票:0回答:1

我想在 R 中安装 data.table 库,但遇到问题。 当我打字时

安装.packages(“数据.表”)

它告诉我必须从源代码编译该库。如果我说“是”,我的 C 编译器就会开始运行,直到出现错误消息“找不到 ”。

所以我也尝试安装zlib.h库(使用MSYS2,我尝试了 pacman -S mingw-w64-i686-zlib 和 pacman -S mingw-w64-x86_64-zlib ),但似乎没有使用。

这是我的完整输出:

imelf@DESKTOP-CFHKUQA MINGW32 /d/Informatik/NachhilfeInfoUni/SteuberHenry/DataAnalysis
$ pacman -S mingw-w64-i686-zlib
resolving dependencies...
looking for conflicting packages...

Packages (1) mingw-w64-i686-zlib-1.3.1-1

Total Download Size:   0.10 MiB
Total Installed Size:  0.40 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] Y
:: Retrieving packages...
 mingw-w64-i686-zlib-1.3.1-...   103.3 KiB   294 KiB/s 00:00 [###############################] 100%
(1/1) checking keys in keyring                               [###############################] 100%
(1/1) checking package integrity                             [###############################] 100%
(1/1) loading package files                                  [###############################] 100%
(1/1) checking for file conflicts                            [###############################] 100%
(1/1) checking available disk space                          [###############################] 100% 
:: Processing package changes...
(1/1) upgrading mingw-w64-i686-zlib                          [###############################] 100%

imelf@DESKTOP-CFHKUQA MINGW32 /d/Informatik/NachhilfeInfoUni/SteuberHenry/DataAnalysis
$ r

R version 4.2.0 (2022-04-22 ucrt) -- "Vigorous Calisthenics"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("data.table");
Installing package into 'C:/Users/imelf/AppData/Local/R/win-library/4.2'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---

  There is a binary version available but the source version is later:
           binary source needs_compilation
data.table 1.15.2 1.15.4              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel)$           
$$
installing the source package 'data.table'

trying URL 'https://ftp.gwdg.de/pub/misc/cran/src/contrib/data.table_1.15.4.tar.gz'
Content type 'application/octet-stream' length 5387593 bytes (5.1 MB)
downloaded 5.1 MB

* installing *source* package 'data.table' ...
** package 'data.table' successfully unpacked and MD5 sums checked
** using staged installation

   **********************************************
   WARNING: this package has a configure script
         It probably needs manual configuration
   **********************************************


** libs
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c assign.c -o assign.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c between.c -o between.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c bmerge.c -o bmerge.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c chmatch.c -o chmatch.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c cj.c -o cj.o      
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c coalesce.c -o coalesce.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c dogroups.c -o dogroups.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fastmean.c -o fastmean.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fcast.c -o fcast.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fifelse.c -o fifelse.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fmelt.c -o fmelt.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c forder.c -o forder.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c frank.c -o frank.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fread.c -o fread.o
In file included from fread.c:21:
fread.c: In function ‘freadMain’:
fread.c:1291:21: warning: array subscript has type ‘char’ [-Wchar-subscripts]
 1291 |       if (isspace(ch[0]) || isspace(ch[nchar-1]))
      |                   ~~^~~
fread.c:1291:39: warning: array subscript has type ‘char’ [-Wchar-subscripts]
 1291 |       if (isspace(ch[0]) || isspace(ch[nchar-1]))
      |                                     ~~^~~~~~~~~
fread.c:1487:34: warning: array subscript has type ‘char’ [-Wchar-subscripts]
 1487 |       while (++ch<eof && isspace(*ch)) {};
      |                                  ^~~
fread.c:1570:29: warning: array subscript has type ‘char’ [-Wchar-subscripts]
 1570 |   while (ch<eof && (isspace(*ch) || *ch=='\0')) {   // isspace matches ' ', \t, \n and \r;  \0 before eof should be skipped too
      |                             ^~~
fread.c:2588:30: warning: array subscript has type ‘char’ [-Wchar-subscripts]
 2588 |     while (ch<eof && isspace(*ch)) ch++;
      |                              ^~~
fread.c:2595:32: warning: array subscript has type ‘char’ [-Wchar-subscripts]
 2595 |       while (ch<eof && isspace(*ch)) ch++;
      |                                ^~~
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c freadR.c -o freadR.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c froll.c -o froll.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c frollR.c -o frollR.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c frolladaptive.c -o frolladaptive.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fsort.c -o fsort.o
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -fopenmp   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c fwrite.c -o fwrite.o
fwrite.c:11:10: fatal error: zlib.h: No such file or directory
   11 | #include <zlib.h>      // for compression to .gz
      |          ^~~~~~~~
compilation terminated.
make: *** [C:/PROGRA~1/R/R-42~1.0/etc/x64/Makeconf:252: fwrite.o] Error 1
ERROR: compilation failed for package 'data.table'
* removing 'C:/Users/imelf/AppData/Local/R/win-library/4.2/data.table'

The downloaded source packages are in
        'C:\Users\imelf\AppData\Local\Temp\RtmpmWL9ps\downloaded_packages'
Warning message:
In install.packages("data.table") :
  installation of package 'data.table' had non-zero exit status
>

有人可以帮忙吗?

r c data.table msys2
1个回答
0
投票

该库的新版本(版本 1.15.4 也可用于 Windows 上的 R 4.2),然后命令

install.packages("data.table")
就可以正常工作了。

然后我可以编译并运行以下示例程序

library("data.table");

DT = data.table(x = rep(c("a","b","c"), each = 3), y = c(1, 3, 6), v = 1:9);

print(DT);
© www.soinside.com 2019 - 2024. All rights reserved.