I'm trying to tell my package to use gcc
to compile the C++
code in stead of clang
. Why aren't my CXX
flags in my Makevars
file being used?
(I am expecting/hoping the solution to be something really simple that I've overlooked.)
It's my understanding (see references) that I can specify CXX*
flags in either
src/Makevars
in the package, or~/.R/Makevars
However, I can't get option 1 to work, only option 2.
Here are screenshots showing the build options I'm using. In each case I'm showing both the Makevars
and the /.R/Makevars
files to show which one I'm using in each case.
Option 1: src/Makevars
Here I specify CXX11 = /usr/local/bin/g++-7
inside src/Makevars
. The build messages say it's building with clang
Option 2: ~/.R/Makevars
Here I specify CXX11 = /usr/local/bin/g++-7
inside ~/.R/Makevars
. The build message shows it builds with g++
I've noticed this on a few packages I've built recently using Rcpp
, but if you want an example to test my googlePolylines
package is here on github.
devtools::session_info()
Session info ----------------------------------------------------------------------------------------------
setting value
version R version 3.4.3 (2017-11-30)
system x86_64, darwin15.6.0 ## Mac OS
ui RStudio (1.1.414)
language (EN)
collate en_AU.UTF-8
tz Australia/Melbourne
date 2018-03-11
Quoting Duncan Murdoch in https://stat.ethz.ch/pipermail/r-package-devel/2017q4/002087.html:
According to section 1.2.1 "Using Makevars" in Writing R Extensions, R_HOME/etcR_ARCH/Makeconf is included after Makevars, so what you're seeing is by design. I believe this is so that packages are built with tools compatible with those that built R. (Remember, packages are designed for distribution to diverse systems.)
So you might change various flags within src/Makevars
via for example PKG_CXXFLAGS
, but you cannot overwrite CXXFLAGS
or CXX
itself. And there is no PKG_CXX
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With