Skip to content

[Rcpp-devel] Advice on making interface into existing C++ library

4 messages · Jeffrey Wong, Dirk Eddelbuettel

#
Hello,

I am very interested in making libFM accessible through R via Rcpp

https://github.com/srendle/libfm

The makefile for libFM will compile the libFM.cpp file in the src/libFM
directory and dump the result in a bin/ directory, which is normally
accessed through command line.  What would be the best way for making this
accessible through Rcpp?
#
On 13 January 2015 at 00:16, Jeffrey Wong wrote:
| Hello,
| 
| I am very interested in making libFM accessible through R via Rcpp
| 
| https://github.com/srendle/libfm
| 
| The makefile for libFM will compile the libFM.cpp file in the src/libFM
| directory and dump the result in a bin/ directory, which is normally accessed
| through command line.? What would be the best way for making this accessible
| through Rcpp??

I'd start with the src/libfm/Makefile, see what it compiles into libfm (ie
*.cpp and tools/{transpose,convert.cpp}) and just copy that to src/ of your
package.  R takes care of the rest.

Working with an external library is doable but harder.  Other R packages do
it, can't think of an Rcpp-using package that does though.

Dirk
#
Thanks Dirk, would I still create a rcpp skeleton package and dump the
*.cpp files into src, then just use Rcpp::export? What about all the .h
files in that library?

Thanks
On Tuesday, January 13, 2015, Dirk Eddelbuettel <edd at debian.org> wrote:

            

  
    
#
On 13 January 2015 at 08:51, Jeffrey Wong wrote:
| Thanks Dirk, would I still create a rcpp skeleton package and dump the *.cpp
| files into src, then just use Rcpp::export? What about all the .h files in that
| library?

Yes you need those too, either in the same directory or in one the compiler
is told as about as eg via PKG_CXXFLAGS = -I../../inst/include  as we often
do when export headers for use by other packages.

Rcpp has 321 reverse dependencies on CRAN. That is 321 worked, and working,
examples of how to do this.  Use them to your advantage.

Dirk