另一个从源安装挑战!我没有看到其他类似问题中提到的我的具体问题,所以在这里发帖。
问题:在 R4.2.3 Windows 上使用 RTools 4.2 从源安装软件包失败
install.packages('units',type = "source")
,并在下面粘贴了错误,以“错误:包'units'编译失败”结尾。
install.packages('terra', repos='https://rspatial.r-universe.dev')
使用最新的开发版本(1.8-0),并通过 Renv 从 Posit 包管理器安装较旧的版本(1.7-78)。具体错误有所不同,但同样以编译失败告终。
options(error = NULL)
sys.getenv("PATH")
中的前两项是
C:\\rtools42\\x86_64-w64-mingw32.static.posix\\bin;C:\\rtools42\\usr\\bin;
,所以看起来就在那里。
Sys.which("make")
返回“C: tools42\usr in\make.exe”
Using built-in specs.
COLLECT_GCC=C:\rtools42\X86_64~1.POS\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/rtools42/x86_64~1.pos/bin/../libexec/gcc/x86_64-w64-mingw32.static.posix/10.4.0/lto-wrapper.exe
Target: x86_64-w64-mingw32.static.posix
Configured with: /root/mxe/tmp-gcc-host-x86_64-w64-mingw32.static.posix/gcc-10.4.0/configure --host=x86_64-w64-mingw32.static.posix --target=x86_64-w64-mingw32.static.posix --build=x86_64-pc-linux-gnu --prefix=/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix --with-native-system-header-dir=/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix/include --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --without-libiconv-prefix --disable-shared --disable-multilib --without-x --disable-win32-registry --enable-threads=posix --enable-libgomp --with-gmp=/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix --with-isl=/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix --with-mpc=/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix --with-mpfr=/usr/lib/mxe/usr/x86_64-w64-mingw32.static.posix --enable-libstdcxx-time target_configargs=XCFLAGS=-Wno-format
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.4.0 (GCC)
详细信息:这是 install.packages('units',type = "source")
的错误 --terra 有更长(且不同)的错误集:
* installing *source* package 'units' ...
** package 'units' successfully unpacked and MD5 sums checked
** using staged installation
**********************************************
WARNING: this package has a configure script
It probably needs manual configuration
**********************************************
** libs
rm -Rf units.dll RcppExports.o udunits.o
g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-42~1.3/include" -DNDEBUG -DUDUNITS2_DIR=0 -I'C:/Users/OPname/AppData/Local/R/win-library/4.2/Rcpp/include' -I"C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-42~1.3/include" -DNDEBUG -DUDUNITS2_DIR=0 -I'C:/Users/OPname/AppData/Local/R/win-library/4.2/Rcpp/include' -I"C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c udunits.cpp -o udunits.o
g++ -std=gnu++14 -shared -s -static-libgcc -o units.dll tmp.def RcppExports.o udunits.o -ludunits2 -lexpat -LC:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64 -LC:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib -LC:/PROGRA~1/R/R-42~1.3/bin/x64 -lR
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64/libudunits2.a(parser.o):parser.c:(.text+0x14a): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64/libudunits2.a(parser.o):parser.c:(.text+0x1fb): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64/libudunits2.a(parser.o):parser.c:(.text+0x343): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64/libudunits2.a(parser.o):parser.c:(.text+0x97e): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64/libudunits2.a(parser.o):parser.c:(.text+0xb0c): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:\Users\OPname\AppData\Local/R/cache/R/renv/extsoft/lib/x64/libudunits2.a(parser.o):parser.c:(.text+0x1060): more undefined references to `__imp___iob_func' follow
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'units'
* removing 'C:/Users/OPname/AppData/Local/R/win-library/4.2/units'
* restoring previous 'C:/Users/OPname/AppData/Local/R/win-library/4.2/units'
Warning in install.packages :
installation of package ‘units’ had non-zero exit status
非常感谢大家!
R CMD INSTALL terra
这应该适用于 R 3.6 及更高版本。在 Windows 上,如果您使用更新版本的 R,
install.packages('terra', repos='https://rspatial.r-universe.dev')
将安装开发版本的二进制版本。所有使用的外部库都附带 RTools,因此 OSGeo4W 不会改变任何内容。在类似 Linux 的系统上安装多个 GDAL/PROJ 库可能会导致问题。