Rtools works for installing from source, but cannot build or use Rcpp

I am unable to run the hello world Rcpp example or build the template R-package

Rcpp:

> library(Rcpp)

>hello <- function() {
+  print("Hello, world!")
+ }

> cppFunction('int add(int x, int y, int z) {
+  int sum = x + y + z;
+  return sum;
+ }')

make: *** No rule to make target 'file32c873a03529.o', needed by 'sourceCpp_2.dll'.  Stop.
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  : 
  Error 1 occurred building shared library.

building sample package:

 devtools::build()

√  checking for file 'D:\Documents\git_repos\testbuild/DESCRIPTION' (364ms)
-  preparing 'testbuild':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'testbuild_0.1.0.tar.gz'
   
character(0)

...and 'testbuild_0.1.0.tar.gz' does not exist.

Checks:

> Sys.which("make")
                              make 
"C:\\rtools40\\usr\\bin\\make.exe" 

> devtools::find_rtools(debug = TRUE)
[1] TRUE

> pkgbuild::find_rtools(debug = TRUE)
[1] TRUE

> pkgbuild::check_rtools(debug = TRUE)
[1] TRUE

> pkgbuild::rtools_path()
[1] "C:\\rtools40/usr/bin"

> pkgbuild::has_build_tools(debug = TRUE)
[1] TRUE

**> .Call("rs_canBuildCpp")**
**[1] FALSE**

Works:

install.packages("jsonlite", type="source")

installing to C:/Program Files/R/R-4.0.2/library/00LOCK-jsonlite/00new/jsonlite/libs/x64
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'jsonlite'
    finding HTML links ... done
    base64                                  html  
    flatten                                 html  
    fromJSON                                html  
    prettify                                html  
    rbind_pages                             html  
    read_json                               html  
    serializeJSON                           html  
    stream_in                               html  
    unbox                                   html  
    validate                                html  
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (jsonlite)

I am appending rtools to the path through .Renviron:
PATH="${RTOOLS40_HOME}\usr\bin;${RTOOLS40_HOME}\mingw64\bin\;${PATH}"

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    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     

loaded via a namespace (and not attached):
 [1] rstudioapi_0.11   magrittr_1.5      usethis_1.6.1     devtools_2.3.0    pkgload_1.1.0     R6_2.4.1          rlang_0.4.7       fansi_0.4.1       tools_4.0.2      
[10] pkgbuild_1.1.0    sessioninfo_1.1.1 cli_2.0.2         withr_2.2.0       ellipsis_0.3.1    remotes_2.1.1     assertthat_0.2.1  digest_0.6.25     rprojroot_1.3-2  
[19] crayon_1.3.4      processx_3.4.3    callr_3.4.3       fs_1.4.2          ps_1.3.3          testthat_2.3.2    memoise_1.1.0     glue_1.4.1        compiler_4.0.2   
[28] desc_1.2.0        backports_1.1.8   prettyunits_1.1.1

Any help is much appreciated.

No actual help from me.
Only a call that it works for me and the output of your function calls in my situation.
Two differences I saw:

  • your output of pkgbuild::rtools_path() has a mix of foreward and backward slashes
  • I did not see Rccp listed under 'other attached packages:'

I hope this is of any use for you.

library(Rcpp)

hello <- function() {
  print("Hello, world!")
 }

 cppFunction('int add(int x, int y, int z) {
  int sum = x + y + z;
  return sum;
 }')

add(2,4,3)
#> [1] 9

Sys.which("make")
#>                                      make 
#> "D:\\tools\\rtools40\\usr\\bin\\make.exe"

devtools::find_rtools(debug = TRUE)
#> Scanning R CMD config CC...
#> cc_path: D:/tools/rtools40/mingw64/bin/gcc 
#> install_path: D:/tools/rtools40 
#> Found compatible gcc from R CMD config CC
#> [1] TRUE

pkgbuild::find_rtools(debug = TRUE)
#> Scanning R CMD config CC...
#> cc_path: D:/tools/rtools40/mingw64/bin/gcc 
#> install_path: D:/tools/rtools40 
#> Found compatible gcc from R CMD config CC
#> [1] TRUE

pkgbuild::check_rtools(debug = TRUE)
#> Scanning R CMD config CC...
#> cc_path: D:/tools/rtools40/mingw64/bin/gcc 
#> install_path: D:/tools/rtools40 
#> Found compatible gcc from R CMD config CC
#> [1] TRUE

pkgbuild::rtools_path()
#> [1] "D:/tools/rtools40/bin"

pkgbuild::has_build_tools(debug = TRUE)
#> Scanning R CMD config CC...
#> cc_path: D:/tools/rtools40/mingw64/bin/gcc 
#> install_path: D:/tools/rtools40 
#> Found compatible gcc from R CMD config CC
#> [1] TRUE
.Call("rs_canBuildCpp")
#> Error in .Call("rs_canBuildCpp"): C symbol name "rs_canBuildCpp" not in load table

sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] 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] Rcpp_1.0.4.6
#> 
#> loaded via a namespace (and not attached):
#>  [1] knitr_1.29        magrittr_1.5      usethis_1.6.1     devtools_2.3.0   
#>  [5] pkgload_1.0.2     R6_2.4.1          rlang_0.4.6       fansi_0.4.1      
#>  [9] stringr_1.4.0     highr_0.8         tools_4.0.2       pkgbuild_1.0.7   
#> [13] xfun_0.15         sessioninfo_1.1.1 cli_2.0.2         withr_2.2.0      
#> [17] remotes_2.1.1     htmltools_0.4.0   ellipsis_0.3.0    rprojroot_1.3-2  
#> [21] yaml_2.2.1        assertthat_0.2.1  digest_0.6.25     crayon_1.3.4     
#> [25] processx_3.4.2    callr_3.4.3       fs_1.4.1          ps_1.3.2         
#> [29] testthat_2.3.2    memoise_1.1.0     glue_1.4.1        evaluate_0.14    
#> [33] rmarkdown_2.3     stringi_1.4.6     compiler_4.0.2    backports_1.1.6  
#> [37] desc_1.2.0        prettyunits_1.1.1

Created on 2020-07-20 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.