R 使用 mingw_32 为 64 位架构编译包 [英] R is using the mingw_32 to compile packages for 64-bit architecture
问题描述
定期 - 我想每当我更新 R - 我在我的 64 位 Windows 机器上从源代码安装包时遇到问题.
Periodically – I think whenever I update R – I have problems installing packages from source on my 64-bit Windows machine.
今天我正在尝试使用 devtools::install_github()
安装一个包.安装在我的笔记本电脑上进行得很好,但我的台式机上没有,它可以在 *** arch - i386
下安装包,但在 *** arch - x64
, 报告错误信息
Today I'm trying to install a package using devtools::install_github()
. The installation proceeded fine on my laptop, but my not on my desktop, which can install the package under *** arch - i386
, but under *** arch - x64
, which reports the error message
C:/PROGRA~1/R/R-34~1.4/bin/x64/R.dll:文件无法识别:文件格式无法识别
C:/PROGRA~1/R/R-34~1.4/bin/x64/R.dll: file not recognized: File format not recognized
导致错误的命令是
C:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o PACKAGENAME.dll [...]
我相信错误的产生是因为 R 正在使用 mingw_32 来尝试编译 64 位包.问题是,我在哪里可以告诉 R 使用 mingw_64?我已经检查了所有我能记得的地方:
I believe that the error is arising because R is using mingw_32 to attempt to compile a 64-bit package. The question is, where can I tell R to use mingw_64? I've already checked all the places that I can recall:
R-3.4.4/etc/x64/Makeconf
状态BINPREF ?= c:/Rtools/mingw_64/bin/
- 我的系统
PATH
(在 R 中使用Sys.getenv('PATH')
验证)在 mingw_32 之前包含 mingw_64.
R-3.4.4/etc/x64/Makeconf
statesBINPREF ?= c:/Rtools/mingw_64/bin/
- My system
PATH
(verified from within R usingSys.getenv('PATH')
) includes mingw_64 ahead of mingw_32.
R 必须寻找其他地方来决定使用哪个编译器...但在哪里?
R must be looking somewhere else to decide which compiler to use... but where?
推荐答案
通过 R CMD 检查未在 Rtools 目录中查找 gcc:
R 在 C:/Users/MYUSERNAME/Documents/.R/Makevars
中查找 BINPREF
的值.删除此文件的内容删除了不正确的位置.
R was looking in C:/Users/MYUSERNAME/Documents/.R/Makevars
for the value of BINPREF
. Deleting the contents of this file removed the incorrect location.
$RPATH/etc/i386/Makeconf
在每次新安装 R 时重新创建,并包含以下行BINPREF ?= c:/Rtools/mingw_32/bin/
.?=
运算符将设置 BINPREF
的值(如果它尚未设置,就像在上面提到的 Makevars
文件中一样).因此,将 ?=
替换为 =
将一直有效,直到安装了新版本的 R 并且 Makeconf
文件被覆盖 - 更新或卸载 R不会修改用户目录中的 Makevars
文件.
$RPATH/etc/i386/Makeconf
is re-created with each new installation of R, and contains the line
BINPREF ?= c:/Rtools/mingw_32/bin/
.
The ?=
operator will set the value of BINPREF
if it is not already set, as it was in the Makevars
file mentioned above. So replacing ?=
with =
will work until a new version of R is installed and the Makeconf
file is overwritten – updating, or uninstalling, R will not modify the Makevars
file in the User directory.
这篇关于R 使用 mingw_32 为 64 位架构编译包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!