C ++ linking with boost in R package

I am making an R package for data streams on networks. For speed, some of the code is written in C ++ and with my own implementation of graph algorithms. I would like to rewrite my code to use the Boost Graph library.

What will I need to put in the Makevars file to set the compiler / linker option for boost search? Sorry, I'm not very familiar with Make.

I am working in Linux environment

Yes, I looked at RBGL but couldn't find a makefile in this package

If it matters, I am using Rcpp for the R and C ++ code interface

+3


source to share


1 answer


It's not that hard. By default, each Rcpp package has a default src/Makevars

which contains

## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`

      

where the library for Rcpp is itself dynamically by giving R. You just expand that and add



-lboost_graph

      

(and / or possibly parallel or mt variants). If you installed them in an unusual location, add flags as well -L...

. Dito for PKG_CFLAGS for header locations.

What about it. See the Manual Writing R Extensions

for more details on creating R packages.

+3


source







All Articles