Discussion:
[Rcpp-devel] Makevars portability
Jeff Newmiller
2018-03-03 17:32:23 UTC
Permalink
I have an existing legacy.c file with legacy.h interface that I am putting into a package. I figured out how to create an rcpp glue file that uses an extern "C" block to include the .h file so my C++ function can call it.

However, it looks like Rcpp is defining the OBJECTS variable before I put legacy.o in, so I have had to use

OBJECTS += legacy.o

in the Makevars file so it will compile and link the legacy code in along with the object files setup by Rcpp, but R CMD check complains about portability.

Is there a way to do this that does not irritate R CMD check?
--
Sent from my phone. Please excuse my brevity.
Dirk Eddelbuettel
2018-03-03 17:52:57 UTC
Permalink
On 3 March 2018 at 09:32, Jeff Newmiller wrote:
| I have an existing legacy.c file with legacy.h interface that I am putting into a package. I figured out how to create an rcpp glue file that uses an extern "C" block to include the .h file so my C++ function can call it.
|
| However, it looks like Rcpp is defining the OBJECTS variable before I put legacy.o in, so I have had to use
|
| OBJECTS += legacy.o
|
| in the Makevars file so it will compile and link the legacy code in along with the object files setup by Rcpp, but R CMD check complains about portability.
|
| Is there a way to do this that does not irritate R CMD check?

In the simplest cases you need _nothing_ in src/Makevars. Just drop files
src/legacy.{c,h} and, say, src/legacyWrapper.cpp in src/, and everything
should work.

That is what the skeleton package does. (For RcppArmadillo we need to link
to BLAS/LAPACK/Fortran/... but not here.)

So if you check existing packages (easy to browse on GitHub too) you should
notice that very few, possibly none, set OBJECTS. None of mine do, methinks.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Jeff Newmiller
2018-03-03 23:11:55 UTC
Permalink
Thanks for the prompt reply, and the slick package. Indeed, it appears to be unnecessary. I must have created it in an attempt to fix another problem and lost track of that.
--
Sent from my phone. Please excuse my brevity.
Post by Dirk Eddelbuettel
| I have an existing legacy.c file with legacy.h interface that I am
putting into a package. I figured out how to create an rcpp glue file
that uses an extern "C" block to include the .h file so my C++ function
can call it.
|
| However, it looks like Rcpp is defining the OBJECTS variable before I
put legacy.o in, so I have had to use
|
| OBJECTS += legacy.o
|
| in the Makevars file so it will compile and link the legacy code in
along with the object files setup by Rcpp, but R CMD check complains
about portability.
|
| Is there a way to do this that does not irritate R CMD check?
In the simplest cases you need _nothing_ in src/Makevars. Just drop files
src/legacy.{c,h} and, say, src/legacyWrapper.cpp in src/, and
everything
should work.
That is what the skeleton package does. (For RcppArmadillo we need to link
to BLAS/LAPACK/Fortran/... but not here.)
So if you check existing packages (easy to browse on GitHub too) you should
notice that very few, possibly none, set OBJECTS. None of mine do, methinks.
Dirk
Loading...