Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use subfolders in 'src/' in R packages?

Tags:

r

rcpp

C or C++ code inside subfolders in the src/ for example src/libfoo don't get compiled when I install a package.

When I searched on other questions I found this that mentions Makevars. I searched the Matrix package Makevars. I I thought that I should add:

PKG_LIBS: -Llibfoo

But that didn't work.

I also found that on Writing R Extensions. I added the following to my Makevars and It didn't work either.

SOURCES = $(libfoo/*.c)
OBJECTS = $(SOURCES:.c=.o)

How should I tweak the Makevars file?

like image 429
Daniel Falbel Avatar asked Mar 28 '18 21:03

Daniel Falbel


1 Answers

It ended up working by setting:

SOURCES = $(wildcard libfoo/*.c)
OBJECTS = foo.o RcppExports.o $(SOURCES:.c=.o)

The really mysterious part for me is the wildcard when defining the SOURCES.

like image 132
Daniel Falbel Avatar answered Oct 01 '22 01:10

Daniel Falbel