mardi 22 mai 2018

Error message "Undefined reference to boost (...)" comes when adding cpp11 plugin

When compiling my .cpp file with Rcpp in R, this error message comes :

undefined reference to `boost::system::generic_category()'

But when I remove the // [[Rcpp::plugins(cpp11)]] line, there isn't any error anymore. Why?

Here is my minimal reproducible example.

// include Rcpp, it takes care of most other headers you need
#include <Rcpp.h>
#include <boost/array.hpp>

// include Boost's odeint
#include <boost/numeric/odeint.hpp>
#include <boost/numeric/odeint/integrate/integrate_adaptive.hpp>
#include <boost/filesystem/fstream.hpp>
#include <functional>

// tell R you need Boost
// [[Rcpp::depends(BH)]]
// [[Rcpp::plugins(cpp11)]]

using namespace Rcpp;
using namespace std;
using namespace boost::numeric::odeint;

typedef boost::array< double ,130 > state_type;

// [[Rcpp::export]]
void my_fun22(Rcpp::NumericVector &x, const double t,const Rcpp::NumericVector theta){
  Function f("mod_cpp");
  x=f(_["t"]=t,_["x"]=x,_["p1"]=theta);
}

Aucun commentaire:

Enregistrer un commentaire