[R-sig-dyn-mod] Using dynamically compiled code for use with deSolve in a new package

Rampal S. Etienne rampaletienne at gmail.com
Wed Nov 29 14:44:54 CET 2017


Dear Thomas,

Thanks again for this reply. While this may work locally and for some
users, it does not work in my case where my namespace file is generated
by roxygen2. Also, CRAN does not like dll-file to be in the package
(inst folder), so it needs to be built at installation. How do I do
this? Simply including the Fortran code in the src directory does not
work (gives error 127, whatever that is). Any suggestions?

Cheers, Rampal


On 11-6-2017 21:15, Thomas Petzoldt wrote:
> Hi,
>
> that's straightforward.
>
> 1) Put deSolve in Depends of your package DESCRIPTION:
>
> Depends: deSolve
>
>
> 2) Import the solver function (e.g. ode or lsoda) in the NAMESPACE of
> your package and declare your dynamic library (.dll or .so)
>
> importFrom(deSolve,ode)
>
> useDynLib(mypackage)
>
>
> 3) and then use this .dll/.so in the call to ode():
>
> ode(...., dllname = "mypackage", .....)
>
>
> An example can be found in package growthrates:
>
> https://github.com/tpetzoldt/growthrates/blob/master/pkg/R/grow_twostep.R
>
> Hope it helps,
>
> Thomas
>
>
>
> On 11.06.2017 13:20, Rampal Etienne wrote:
>> Dear all,
>>
>> I have written C and FORTRAN functions to use with deSolve and found
>> that it works significantly faster than the analogous R functions. So
>> far so good! However, now I want to build a package that uses this code.
>> How do I do this? I can include the DLL in the package (so no more
>> compilation by the user of the package, just loading it), but then the
>> user needs to be able to find it. Where will this be installed? That may
>> be different on different systems. Any suggestions?
>>
>> Cheers, Rampal
>>
>> _______________________________________________
>> R-sig-dynamic-models mailing list
>> R-sig-dynamic-models at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
>
>



More information about the R-sig-dynamic-models mailing list