Using boost multiprecision with Rcpp on Windows

谁都会走 提交于 2019-12-24 21:20:56

问题


I'm trying to compile and use the following code (which I have seen on SO):

// [[Rcpp::depends(BH)]]
#include <Rcpp.h>
#include <boost/multiprecision/float128.hpp>

namespace mp = boost::multiprecision;

// [[Rcpp::export]]
std::string mexp(double mx)
{
  mp::float128 x(mx);
  mp::float128 res = mp::exp(x);
  return res.convert_to<std::string>();
}

Before compiling, I have to do Sys.setenv("PKG_LIBS" = "-lquadmath") otherwise the compilation does not work. Then the compilation runs fine, but when I type mexp(1) in R, the R session totally crashes. Am I missing something ? The session crashes in RStudio as well as in the classical R gui.

PS: I am under Windows and I get the crash with R-3.3.3 as well as R-3.4.1.

Edit:

Just tried on Linux with R-3.4.1 and this works fine. I even don't need to do Sys.setenv("PKG_LIBS" = "-lquadmath").

来源:https://stackoverflow.com/questions/45679263/using-boost-multiprecision-with-rcpp-on-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!