3

I am running a new installation of R 3.3 on a Windows 7 virtual machine, and trying to install my own R package that uses Rcpp. The package is available on GitHub. I have installed Rtools and both Rcpp and devtools

Using devtools::install_github("pbsag/tcadr"):

> devtools::install_github("pbsag/tcadr")
Downloading GitHub repo pbsag/tcadr@master
from URL https://api.github.com/repos/pbsag/tcadr/zipball/master
Installing tcadr
"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/Greg/AppData/Local/Temp/Rtmpwvw2qc/devtools1814572d2483/pbsag-tcadr-8ae1a82"  \
  --library="\\Mac/Home/Documents/R/win-library/3.3" --install-tests 

* installing *source* package 'tcadr' ...
** libs
c:/Rtools/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-33~1.0/include" -DNDEBUG    -I"\\Mac/Home/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp:4:18: fatal error: Rcpp.h: No such file or directory
 #include <Rcpp.h>
                  ^
compilation terminated.
make: *** [RcppExports.o] Error 1
Warning: running command 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="tcadr.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o get_df_from_binary.o write_df_to_binary.o"' had status 2
ERROR: compilation failed for package 'tcadr'
* removing '\\Mac/Home/Documents/R/win-library/3.3/tcadr'
Error: Command failed (1)

Cloning the repo and building within Rstudio:

==> Rcmd.exe INSTALL --no-multiarch --with-keep.source tcadr

* installing to library '\\Mac/Home/Documents/R/win-library/3.3'
* installing *source* package 'tcadr' ...
** libs
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o tcadr.dll tmp.def RcppExports.o get_df_from_binary.o write_df_to_binary.o -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.0/bin/x64 -lR
C:\Rtools\mingw_64\bin\nm.exe: RcppExports.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: get_df_from_binary.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: write_df_to_binary.o: File format not recognized
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 'tcadr'
* removing '\\Mac/Home/Documents/R/win-library/3.3/tcadr'

Exited with status 1.

This question has the same error, but that accepted answer does not apply because I don't have any compiled object files in my git repository.

Note that I have no problems building this package in 3.2 on Windows 7 or on Mac.


Session Info

R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_1.11.1

loaded via a namespace (and not attached):
[1] httr_1.1.0     R6_2.1.2       tools_3.3.0    withr_1.0.1    rstudioapi_0.5
[6] curl_0.9.7     memoise_1.0.0  git2r_0.15.0   digest_0.6.9 
Community
  • 1
  • 1
gregmacfarlane
  • 2,121
  • 3
  • 24
  • 53

2 Answers2

5

I recently had to deal with this same issue on a Windows server. The issue is related to the Rtools version needing to be v3.4 instead of v3.3 to work with R v3.3.0.

Furthermore, you need to remove the old Rtools' paths from your system's PATH variable before reinstall!:

c:\Rtools\bin and c:\Rtools\gcc-4.x-y\bin

Download Rtools from https://cran.r-project.org/bin/windows/Rtools/

Edit 1

By default, it looks like Rtools 3.4. is setup to include these two paths on install:

c:\Rtools\bin
c:\Rtools\mingw_32\bin

Edit 2

Few things with RTools, you have:

  1. R toolset
  2. Cygwin DLLs
  3. R 3.3.x + 32 bit toolchain
  4. R 3.3.x + 64bit toolchain

Make sure all of the above are checked.

Next, try to installing the package dependencies by yourself:

install.packages(c("Rcpp","dplyr","data.table","testthat"))

After you clone the repo from GitHub and open the project file. Try going to the Build tab in RStudio, then selecting More -> Clean and Rebuild.

coatless
  • 20,011
  • 13
  • 69
  • 84
  • Good point, nevertheless I have Win 7, R 3.3.0 and RTools 3.3 and all works fine. But perhaps it´s the solution for this problem. – J_F Jun 15 '16 at 17:04
  • I am using Rtools 3.4 – gregmacfarlane Jun 15 '16 at 17:36
  • `Sys.getenv("PATH")` – coatless Jun 15 '16 at 17:40
  • `"C:\\Program Files\\R\\R-3.3.0\\bin\\x64;c:\\Rtools\\bin;c:\\Rtools\\mingw_64\\bin;C:\\Program Files (x86)\\Parallels\\Parallels Tools\\Applications;C:\\Program Files (x86)\\Intel\\MPI-RT\\4.1.0.023\\em64t\\bin;C:\\Program Files (x86)\\Intel\\MPI-RT\\4.1.0.023\\ia32\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Java\\jdk1.7.0_04\\bin\\;C:\\Program Files\\Git LFS"` – gregmacfarlane Jun 15 '16 at 17:48
  • Under `parallels`, with the same setup, I cannot reproduce the issue. After you clone the repo from GitHub and open the project file. Try going to the `Build` menu, `More` -> `Clean and Rebuild`. – coatless Jun 15 '16 at 17:57
  • 1
    Also, try `devtools::build_win()` – coatless Jun 15 '16 at 17:58
  • Few things with RTools, you have `R toolset`, `Cygwin DLLs`, `R 3.3.x + 32 bit toolchain` and `R 3.3.x + 64bit toolchain`. – coatless Jun 15 '16 at 18:16
  • `devtools::build_win()` gave me a package that I can install, but it still doesn't figure out why R can't seem to find the Rcpp headers. – gregmacfarlane Jun 15 '16 at 18:18
  • 2
    Maybe don't install in a directory with spaces per the 'R for Windows' FAQ 2.2. – Dirk Eddelbuettel Jun 15 '16 at 18:23
  • @DirkEddelbuettel, do you mean the package libraries, or R itself? My libraries are in a path with no spaces, but the R installer puts R in `C:\Program Files\` by default; it seems strange to advise against a default behavior. Though I do see the note about building from source... – gregmacfarlane Jun 15 '16 at 18:35
  • @gregmacfarlane try nuking the virtual image and starting over? Best that I can think of. – coatless Jun 15 '16 at 18:42
0

I did a few things on my way to a solution, any one of which might have worked, but in cocktail I now am installed and ready to go.

  1. Install R to C:\R\R-3.3.0, as suggested by @dirkEddelbuettel
  2. Make C:\R\R-3.3.0 writable, so that I can install packages to its internal library.
  3. Install the development version of devtools (you will need devtools to do this: install.packages("devtools"); devtools::install_github("hadley/devtools")
  4. Install both the 32- and 64-bit versions of Rtools, even if using a 64-bit computer.
gregmacfarlane
  • 2,121
  • 3
  • 24
  • 53
  • the last bit is the most important. I had a similar experience 2 + years ago: http://stackoverflow.com/questions/19885381/rtools-not-being-detected-by-r – coatless Jun 15 '16 at 22:01
  • 2
    Also, n.b. R's windows Makeconf for 32 and 64 bit have hard-coded C:\Rtools\ paths, so if you installed to C:\Rtools-3.4 (as I did), you get build errors, or use of an unexpectedly old Rtools. – Jack Wasey May 14 '17 at 18:58