[Rd] including DLL in a package

Sharpie chuck at sharpsteen.net
Tue Aug 24 18:47:51 CEST 2010



loosmart wrote:
> 
> Good afternoon! 
> 
> It may seem trivial to some/most of You, but I found it difficult to
> properly include a C++-based .dll into a package that I want to build for
> usage in R. I read through the "Writing R extensions..." & "R
> administration ..." instructions, but it seems I did not grasp the bigger
> picture.
> 
> The way I figured out to use the .dll in my package finally worked for
> using that package from the R console, but it gives multiple error and
> warning messages when running the RCMD check pkg command in the shell.
> 
> What I did: I created the package skeleton via package.skeleton()
> including a function that makes (1) a
> library.dynam() call to a .dll and (2) a .C() call including the name of
> the function in that DLL. Next, I run RCMD INSTALL pkg to install the
> package and then created a /lib folder in the installed package containing
> the .dll file.
> I tried alternatives, e.g., (a) containing a /src folder in may package
> skeleton with the .dll in it and/or (b) including zzz.R with a .First.lib
> function including the library call .... but nothing worked out when
> running the package check.
> 
> help! thank You very much, MArtin
> 

Hi Martin,

I wrote a detailed example to a similar question on R-help.  It can be
viewed at:

http://r.789695.n4.nabble.com/Writing-own-simulation-function-in-C-td1580190.html#a1580423

The source code mentioned in the post can be obtained from:

http://gist.github.com/323498


The example was for C and not C++, but maybe it can help you get the package
building correctly.  Basically:

1) Write your C functions and put them in the /src directory of the package.

2) Write R wrappers for the C functions and put them in the /R directory
along with a zzz.R that includes a .First.Lib() which calls library.dynam().


With these requirements satisfied both R CMD INSTALL and R CMD build
--binary should be able to produce working packages.  Example files that
satisfy the points above are included in the source code I linked to.

Hope this helps!

-Charlie

-----
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: http://r.789695.n4.nabble.com/including-DLL-in-a-package-tp2336420p2336992.html
Sent from the R devel mailing list archive at Nabble.com.



More information about the R-devel mailing list