2

I have 9 cpp files in /src - 8 from Rcpp and 1 from TMB. I can compile all and run code successfully OR get passed the CRAN checks. But not both.

Method 1

Let R compile all cpp files and generate a single DLL: 'mypackage.dll' and TMB::MakeADfun(..., DLL="mypackage"):

  • passes all CRAN checks (except note on installed package size, see below).
  • Rcpp functions work fine
  • call to TMB function results in: Error in .Call("getParameterOrder", data, parameters, new.env(), PACKAGE = DLL) : "getParameterOrder" not available for .Call() for package "mypackage"
  • using TMB::MakeADFun(..., DLL="mypackage", checkParameterOrder=FALSE) results in: Error in .Call("TMBconfig", e, as.integer(1), PACKAGE = DLL) : "TMBconfig" not available for .Call() for package "mypackage"

Method 2

Use 'makevars.win' following this suggestion, add useDynLib MyTMB, and TMB::MakeADfun(..., DLL="MyTMB") and create two DLLs (mypackage.dll and MyTMB.dll):

makevars.win:

all: MyTMB.dll

MyTMB.dll: MyTMB.cpp
    $(R_HOME)/bin$(R_ARCH_BIN)/Rscript --vanilla -e "TMB::compile('MyTMB.cpp', safebounds=FALSE, safeunload=FALSE)"

clean:
  rm -rf *o
  • both Rcpp and TMB functions work
  • devtools::check() results in one warning for each of the Rcpp functions:

    checking foreign function calls ... WARNING
        Foreign function calls to a different package:
          .Call("_rcppfunction1", ..., PACKAGE = "mypackage")
    
  • and one note on large installed package size. The libs sub-directory is over 30 Mb and about twice the size of Method 1.

Rcpp developers recommend not to use a makevars file, and obviously I'm overwriting something from Rcpp to cause the 'foreign function calls' issue, even though the package is the current package. It seems my options are:

  • modify 'makevars' to restore the Rcpp defaults that avoid the warning, and plead with CRAN to accept the note on installed package size. Not sure how to do the former.
  • find fix to Method 1 problem, and plead with a smaller installed package size. Would be the simplest solution with only one dll. Not sure if the problem is caused because I'm compiling both Rcpp and TMB, and if so, how to fix it.
  • or something else that I'm missing.

Any suggestions?

R details:

platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.3

Alex
  • 15,186
  • 15
  • 73
  • 127
Adrian
  • 684
  • 3
  • 20
  • The GetParemeterOrder error is because dyn.load() is missing? – Wave Sep 29 '17 at 18:36
  • I should have made it clear - I have `useDynLib(mypackage)` in Namespace for Method 1, and Rcpp code works fine, i.e finds the dll. – Adrian Sep 29 '17 at 20:32
  • Sorry, this is not answering your question, but I am wondering how you get method 2 to compile your `mypackage.dll` from the `Rcpp` files? When I use a custom `makefile.win` to compile the `TMB` files, I get this error: `Error in library.dynam(lib, package, package.lib) : DLL 'debugrcpp' not found: maybe not installed for this architecture?`, i.e. it does not compile the `Rcpp` files if a `makefile` is supplied. – Alex Oct 23 '17 at 02:59
  • @Alex Does your makefile look like mine? My Rcpp compiled automagically and the TMB makefile didn't seem to affect it – Adrian Oct 24 '17 at 17:46
  • My makefile looks similar to yours. I use the one in the linked thread: https://github.com/kaskr/adcomp/issues/43#issuecomment-301679794 – Alex Oct 24 '17 at 20:52
  • My problem is when you delete 'mypackage.dll' it doesn't rebuild automatically if there is a makefile present. I now have a work-around which I will post up but I am not sure whether it will pass CRAN checks (but don't see why it would not). – Alex Oct 24 '17 at 20:54
  • see: https://stackoverflow.com/a/46920113/2109289 – Alex Oct 24 '17 at 21:15

0 Answers0