R CMD check looks for a nonexisting .R file when preparing package for lazy loading, Rcpp.package.skeleton produces seemingly corrupted RcppExports.cpp file.
I am trying to build an R-package using Rcpp setting it up with a call to Rcpp.package.skeleton. This produces a seemingly corrupted RcppExports.cpp file (duplicate function definitions).
After manually correcting this file I run devtools::check() on this, compilation and linking succeeds and the dll is built. But then the following output from R CMD check
** R
** data
** byte-compile and prepare package for lazy loading
Reading DataUtils.R
Reading Env.R
Reading Paths.R
Reading RcppExports.R
Reading StatUtils.R
Reading SynData.R
Warnung in file(filename, "r", encoding = encoding)
cannot open file 'src/Env.R': No such file or directory
Error in file(filename, "r", encoding = encoding) :
cannot open file connection
Error : unable to load R code in package 'ZA'
ERROR: lazy loading failed for package 'ZA'
* removing 'C:/Users/MeyerM/Projects/R/ZA/ZA.Rcheck/ZA'
In R CMD INSTALL
Why would it look for a file "src/Env.R"?
The package can be obtained from https://github.com/spyqqqdia/ZAp (file ZAp.zip).
Thanks in advance!
There are many errors in that code:
// [[Rcpp::export]]
before function declaration and definition. This leads to the redefinition errors from compiling RcppExports.cpp
.string
instead of std::string
or using std::string
in some files.Code that must not be part of a package, e.g. compileCpp.R
:
source("src/Env.R")
library(Rcpp)
As a first approximation, files in R
should only contain function definitions.