[R-pkg-devel] Using the correct R binary in configure script

Dirk Eddelbuettel edd at debian.org
Sat Sep 26 19:23:34 CEST 2015


On 26 September 2015 at 12:32, Jack Wasey wrote:
| Dirk, thanks for detailed reply. I may not have explained myself well enough. I
| think the problem is that the recommended configure command assumes 'R', not

If and only if R_HOME is unset. But witness:

  edd at max:~$ R --slave -e 'Sys.getenv("R_HOME")'
  [1] "/usr/lib/R"
  edd at max:~$ RD --slave -e 'Sys.getenv("R_HOME")'
  [1] "/usr/local/lib/R-devel/lib/R"
  edd at max:~$

You don't have to take my work for it, but maybe you trust Writing R Extensions.
And with RHOME set to this, the rest of confiure.{ac,in} uses it.  From
nloptr where I helped Jelmer to generalize his setup:

   ## Set R_HOME, respecting an environment variable if set 
   : ${R_HOME=$(R RHOME)}
   if test -z "${R_HOME}"; then
       AC_MSG_ERROR([Could not determine R_HOME.])   
   fi

   ## Get R compilers and flags
   NLOPT_CC=$("${R_HOME}/bin/R" CMD config CC)
   NLOPT_CFLAGS=$("${R_HOME}/bin/R" CMD config CFLAGS)
   NLOPT_CPP=$("${R_HOME}/bin/R" CMD config CPP)
   NLOPT_CPPFLAGS=$("${R_HOME}/bin/R" CMD config CPPFLAGS)
   NLOPT_CXX=$("${R_HOME}/bin/R" CMD config CXX)
   NLOPT_CXXFLAGS=$("${R_HOME}/bin/R" CMD config CXXFLAGS)
   NLOPT_CXXCPP=$("${R_HOME}/bin/R" CMD config CXXCPP)

See the source:

   https://github.com/jyypma/nloptr/blob/master/configure.ac#L106-L119

| the actually running RD, Rdevel etc, when inferring R_HOME. I can indeed set
| R_HOME, but I want my configure script to be able to figure out which R is
| running, and thus which R_HOME to use when it is not set.
| 
| Your RQuantLib seems to use the same bare 'R RHOME', yet if a package is R
| CMD installed with RD, the configure script will in fact not run RD, but R, to
| find R_HOME. I think it is usually not apparent because the compile flags
| derived from R_HOME/bin/R CMD config are usually the same or similar, but when,
| in my case, I have R compiled with OpenMP, and RD with sanitizers, but without
| OpenMP, this fails because of the discrepancy.
| 
| Again, I feel like I'm missing something obvious, but I hope my explanation of
| what I think is happening may help you guide me.

No I think it beats me, so I'll retire from this thread.  Maybe you can
'diassemble' a few of the existing configure.{ac,in} on CRAN.  There are
hundreds to choose from.

Dirk

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



More information about the R-package-devel mailing list