*.o: File format not recognized on Windows 7

£可爱£侵袭症+ 提交于 2019-12-20 03:24:05

问题


I wrote an R package called arbintools for some work-related data analysis and put it on Github. I wrote it and have been using it on my Mac for a while without issue; Today, I tried to install the dev-1 branch on a Windows 7 laptop and something related to compiling some Rcpp functions seems to go wrong:

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

I get this:

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)

Installing other packages requiring some compilation (like dplyr) worked fine. I also updated R on my Mac to the same version (3.3.0) and reinstalled the package successfully, it's just on the Windows PC it doesn't work. This is beyond my understanding, if anyone has a suggestion or solution I'd be very grateful.


回答1:


The issue is the .so and .o files are only viable with the same architecture e.g. OS X is 64 bit and Windows is 32bit (mingw_32). Please remove them from dev-1/src and then you should be good to go. These files are automatically built on package install as they are the result of using a compiler.

After they are removed, try to create a .gitignore file with the following:

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

This will make OS specific files not selectable for staging and, in turn, commits.

As a general rule of thumb, only keep .cpp or .h files within /src while using Rcpp.



来源:https://stackoverflow.com/questions/37189183/o-file-format-not-recognized-on-windows-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!