[Rcpp-devel] Rcpp11 being checked by Travis CI with minimal example

Dirk Eddelbuettel edd at debian.org
Wed Mar 16 19:42:41 CET 2016


On 16 March 2016 at 19:25, Richel Bilderbeek wrote:
| I am working on a minimal example of using Rcpp11 and Travis CI, which I keep

Did you mean Rcpp11? Or did you mean 'Rcpp with C++11'?  There are several
project of the latter type on CRAN.

| at this GiHub: https://github.com/richelbilderbeek/travis_qmake_gcc_cpp11_rcpp
| . It has one function that is labeled 'noexcept', thus C++11.
| 
| I can compile and run the C++11 code from a Qt Creator project file (called
| 'domagic.pro'),
| I can successfully create the 'domagic' package that uses an R function to call
| the C++11 function.

That is pretty irrelevant to us here because this list is about an R
extension package with a very specific (and different) way of building
things.

| Because Travis CI does not automate multiple languages yet, I want it to check
| the R package automatically. I got this working for C++98 (at this GitHub:
| https://github.com/richelbilderbeek/travis_qmake_gcc_cpp98_rcpp ).
| 
| For C++11 there is one extra step: one has to run the following line in RStudio
| (a tip from Dirk Edelbuettel):
| Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
| When I then run 'devtools::check()' on the package, everything works without
| notes/warnings/errors.

Read 'Writing R Extensions' to learn how to tell R about C++11 for an entire
package.  You can do that in src/Makevars{.win} (which is my preferred way)
or in DESCRIPTION.
 
| But how to let Travis CI do the same? I tried to add it to the .travis.yml, but
| this was more guessing than first reading how to do so. Also adding 'Rcpp11' to
| the package DESCRIPTION, adding [[Rcpp11::export]] or [[export]] to the C++11
| function documentation are ideas that I have tried in multiple random ways.
| 
| Can it be done? Are there suggestions?

You may need to tell Travis about a more modern compiler.  At some point in
the past you needed to be explicit and eg my RcppTOML package has an example
for that--it loads another g++ Ubuntu package set from a PPA.

In more recent times you were also able to switch Travis from Ubuntu 12.04
("precise") to Ubuntu 14.04 ("trusty") and with that you may get by. My
GitHub projects RcppKalman, RcppMsgPack and RQuantLib all do that; only the
latter one is on CRAN (but CRAN is orthogonal to that question).

In general, I do have a few projects on GitHub and CRAN where I specify
C++11. A possibly incomplete list is RcppAnnoy, RcppBDT, RcppCCTZ,
RcppMsgPack, RcppTOML.

Hope this helps,  Dirk



-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list