R: C++ Optimization flag when using the inline package

前端 未结 2 1354
故里飘歌
故里飘歌 2020-12-09 16:49

In R when using the cxxfunction from the inline package, how does one change the optimization flag for the cpp compiler?

By default, on my machine, it compiles with

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 17:34

    There are a couple of options:

    1. The best solution is to modify this for all usage by R so create e.g. a file ~/.R/Makevars and set CFLAGS, CXXFLAGS, ... there. This will affect all use by R CMD INSTALL ..., R CMD SHLIB ... etc pp and as cxxfunction() from inline uses it, it works here too.

    2. Specific to inline and Rcpp: modify the plugin, that's why it is a plugin system. See Rcpp:::Rcpp.plugin.maker().

    3. Switch back from cxxfunction() to cfunction(), hence do not use a plugin and set all arguments manually.

    Needless to say, I like option 1 and use it myself.

    Edit: A fourth (and crude !!) method I used to use in the past is to edit $R_HOME/Makeconf and/or Makeconf.site.

提交回复
热议问题