[Rd] Samples of external code with various compilers?
Mon Dec 2 17:09:13 2002
On Mon, 2 Dec 2002, Duncan Murdoch wrote:
> On Mon, 2 Dec 2002 08:07:19 +0000 (GMT), you wrote in message
> >I think there is information and lots of examples already for Fortran.
> I was thinking of two additions:
> 1. Rewriting the samples in sections 4.2 and/or 4.5 in Fortran,
> Delphi, etc. I might make them a little more elaborate, e.g. showing
> how to return a character string.
(Except the last is non-portable for Fortran). Contributions welcome, of
> 2. Write up the details of how to do it in various specific
> compilers. For example, if you're using Microsoft Visual Fortran, how
> do you create a DLL, how do you set the exported entry points, what
> bugs do you need to work around.
I think it is only an issue on Windows. That needs to go in
readme.packages: some is already there.
> >Base R has only interfaces for C and Fortran (and that via C-style
> >linkage): SJava adds .Java. So is the issue how to write in other
> >languages to use a C interface? `how to dyn.load functions' is easy: you
> >just create an appropriate compiled object, a shared library, a DLL or (on
> >MacOS X as I understand it) a module. The issues seem to be to export the
> >symbols correctly, and even more to import ones from R correctly.
> Yes, that's the main issue. There are also issues even with C: if
> you're using some compiler other than gcc, you probably won't compile
> using R SHLIB, so what do you need to do?
You can: I do it all the time. If you use use the same compilers to build
R and its extensions, it just works.
Brian D. Ripley, email@example.com
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595