terry leitch
terry leitch

Reputation: 31

Source build of Rquantlib fails

I'm building Rquantlib from source and I recently have been encountering this issue:

Error in .Call("RQuantLib_setEvaluationDate", PACKAGE = "RQuantLib", evalDate) : "RQuantLib_setEvaluationDate" not available for .Call() for package "RQuantLib" Error : unable to load R code in package ‘RQuantLib’

R version 3.2.3 (2015-12-10) Rcpp version 0.12.4

I have checked and setEvaluationDate() is there with appropriate rcpp tags, so not sure what's changed. I have not edited the file. It seems to be an inline version, wheras the github version is an actual call:

My rcpp generated inlcude verion for the function:

inline bool setEvaluationDate(QuantLib::Date evalDate) {
     typedef SEXP(*Ptr_setEvaluationDate)(SEXP);
     static Ptr_setEvaluationDate p_setEvaluationDate = NULL;

 }

From github:

bool setEvaluationDate(QuantLib::Date evalDate);
static SEXP RQuantLib_setEvaluationDate_try(SEXP evalDateSEXP) {
BEGIN_RCPP
    Rcpp::RObject __result;
    Rcpp::traits::input_parameter< QuantLib::Date >::type     evalDate(evalDateSEXP);
    __result = Rcpp::wrap(setEvaluationDate(evalDate));
    return __result;
END_RCPP_RETURN_ERROR
}

Upvotes: 2

Views: 149

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368647

You need to recompile all dependents of Rcpp after major upgrades.

Eg when we went from Ubuntu 15.04 to 15.10 which changed the compiler to g++-5 with its new ABI, ran this this script to rebuild everything from the local repo:

#!/usr/bin/env r

## installed packages
IP <- installed.packages()

## all local packages
AP <- available.packages(contrib.url(getOption("repos")[["local"]]))

## all packages known to us
allAP <- available.packages()

pkgs <- "Rcpp"
deps <- tools::package_dependencies(packages=pkgs, db=IP, reverse=TRUE)

## set of dependencies
alldeps <- unique(sort(do.call(c, deps)))
cat("Installing these:\n")
print(alldeps)

## this makes sense on Debian where no packages touch /usr/local
libloc <- Sys.getenv("LIBLOC", unset="/usr/local/lib/R/site-library")

install.packages(alldeps, lib=libloc)

It is similar when something in Rcpp changes, though we've been pretty good about not changing interfaces. But when in doubt, rebuild. Also re-run compileAttributes() if in doubt but little changed there.

Edit: I just (re-)installed without a glitch on two systems too.

Edit 2: It also works directly at the R prompt:

## what follows was one line in R and just broken up for display 
R> cppFunction("bool mySetEvalDate(QuantLib::Date d) "
              "{ QuantLib::Settings::instance().evaluationDate() = d;"
              " return true; }", depends="RQuantLib")
R> mySetEvalDate( Sys.Date() )
[1] TRUE
R> 

Now, if your intent was to call setEvaluationDate() from C++ then you need to look at the discussion about exporting to R and C++ in the Rcpp Attributes vignettes. The code in src/daycounter.cpp is meant for R.

Upvotes: 1

Related Questions