【问题标题】:*.o: File format not recognized on Windows 7*.o:文件格式在 Windows 7 上无法识别
【发布时间】:2016-05-12 13:58:39
【问题描述】:

我为一些与工作相关的数据分析编写了一个名为arbintools 的R 包,并将其放在Github 上。我写了它,并在我的 Mac 上使用了一段时间,没有问题;今天,我尝试在 Windows 7 笔记本电脑上安装dev-1 branch,但与编译某些 Rcpp 函数相关的内容似乎出错了:

devtools::install_github("mjlacey/arbintools", ref = "dev1")

我明白了:

Downloading GitHub repo mjlacey/arbintools@dev1
from URL https://api.github.com/repos/mjlacey/arbintools/zipball/dev1
Installing arbintools
"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  "C:/Users/matla332.USER/AppData/Local/Temp/Rtmp8WWkKC/devtools124c45026af1/mjlacey-arbintools-41dc363"  \
  --library="C:/Users/matla332.USER/Documents/R/win-library/3.3"  \
  --install-tests 

* installing *source* package 'arbintools' ...
** libs

*** arch - i386
C:\Rtools\mingw_32\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_32\bin\nm.exe: Rcpp_functions.o: File format not recognized
c:/Rtools/mingw_32/bin/g++ -shared -s -static-libgcc -o arbintools.dll tmp.def RcppExports.o Rcpp_functions.o -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.0/bin/i386 -lR
RcppExports.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'arbintools'
* removing 'C:/Users/matla332.USER/Documents/R/win-library/3.3/arbintools'
* restoring previous 'C:/Users/matla332.USER/Documents/R/win-library/3.3/arbintools'
Error: Command failed (1)

安装需要一些编译的其他包(如dplyr)工作正常。我还在我的 Mac 上将 R 更新到相同的版本(3.3.0)并成功重新安装了软件包,只是在 Windows PC 上它不起作用。这超出了我的理解,如果有人有任何建议或解决方案,我将非常感激。

【问题讨论】:

    标签: r rcpp


    【解决方案1】:

    问题是 .so.o 文件仅适用于相同的架构,例如OS X 是 64 位,Windows 是 32 位 (mingw_32)。请从dev-1/src 中删除它们,然后您就可以开始了。这些文件是在安装包时自动构建的,因为它们是使用编译器的结果。

    删除后,尝试使用以下内容创建.gitignore 文件:

    src/*.o
    src/*.so
    src/*.dll
    

    这将使特定于操作系统的文件无法选择用于暂存,进而无法选择提交。

    作为一般经验法则,在使用Rcpp 时,仅将.cpp.h 文件保留在/src 中。

    【讨论】:

    • 值得注意的是,即使不是因为这个不兼容,编译后的文件也不属于src文件夹(也不属于版本控制,但是devtools将源版本控制和分发混为一谈所以这是有理由的)。
    • 支持“devtools 将源代码版本控制和分发相结合”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    • 1970-01-01
    • 1970-01-01
    • 2021-01-13
    • 2013-06-12
    相关资源
    最近更新 更多