[R] calling a DLL/shared lib from R directly?

Thomas Lumley tlumley at u.washington.edu
Mon Sep 23 20:25:45 CEST 2002


On Mon, 23 Sep 2002, Jeff D. Hamann wrote:

> Is it possible to call a basic function/subroutine in a DLL/shared lib from
> within R without having to build an R package?

Certainly. You can load the code with dyn.load and then call it with .C or
.Fortran.

At least under Unix it's usually easier to make a package.

	-thomas


>  I have a function like:
>
>  void __stdcall testfunc2(
>    unsigned long a,
>    double b,
>    unsigned long c  )
>  {
>    return a * b * c;
>  }
>
>  or=20
>
>   subroutine fortran_2002_bh_age (sp,site,total_age,bh_age)
>   integer*2 sp
>   real*4 site=20
>   real*4 total_age
>   integer*2 bh_age
>
>   real*4 x
>
>   bh_age =3D some_value
>
>   end subroutine
>
>  I have been able to make it happen from the "writing R extensions" docs. =
>  It pretty important that this library be R independent.=20
>
>  I only get the digest version, so if you answer, could you send a copy =
>  to my email address please?
>
>  Thanks,
>  Jeff.
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle
^^^^^^^^^^^^^^^^^^^^^^^^
- NOTE NEW EMAIL ADDRESS

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list