[R-pkg-devel] Package building - compiling multiple dll files from within src directory

Duncan Murdoch murdoch.duncan at gmail.com
Sat May 6 01:17:06 CEST 2017


On 05/05/2017 2:09 PM, Mark wrote:
> Hi Uwe,
>
> Thank you, I have a series of cc files that use similar function names, so to avoid overriding functions, I thought to compile and load each of the cc files separately. In more detail, I have a series of models for the use in deSolve, they all have the same initmod and derivs internal functions. See 2.2 section: https://cran.r-project.org/web/packages/deSolve/vignettes/compiledCode.pdf
>
> I realised I need to define the makevars file, but I don't know where to start, would you be able to advise on how to structure the makevars file?

You can't.  As Uwe said, you need a full Makefile and also a 
Makefile.win (which is the version of the Makefile used on Windows). 
This is not recommended, it is at your own risk, etc.

So my advice would be:  "Don't do that."

Make the functions you aren't exporting "static", and it doesn't matter 
if the names in separate files clash.  (At least this is true in C; I 
assume C++ is similar.)  Just make sure that the exported names don't 
clash, and put them all into one DLL.

Duncan Murdoch

>
> Best,
>
> M.
>
> On May 05, 2017, at 09:26 AM, Uwe Ligges <ligges at statistik.tu-dortmund.de> wrote:
>
> Why do you want to build separate dll files if you want to load all of
> them anyway? That way you add some overhead, at least.
>
>
> From Writing R Extensions:
>
> "A few packages use the src directory for purposes other than making a
> shared object (e.g. to create executables). Such packages should have
> files src/Makefile and src/Makefile.win (unless intended for only
> Unix-alikes or only Windows)."
>
> Best,
> Uwe Ligges
>
>
>
> On 04.05.2017 17:09, Mark wrote:
> Hi,
>
> I am creating an R package with multiple c files within src directory.
> If possible, I would like to create separate dll files for each c file.
> Also I would like those dll files to have the same name as the input c
> files. i.e:
> mod01.c -o mod01.dll
> mod02.c -o mod02.dll
> mod03.c -o mod03.dll
> ...
>
> I could then load different dll files in the NAMESPACE:
> useDynLib("mod01")
> useDynLib("mod02")
> useDynLib("mod03")
> ...
>
> I don't know how can I set the MAKEVARS to do this correctly, and any
> suggestions would be much appreciated.
>
> Mark
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list