Compile Fortran dll for use in R

Compile Fortran dll for use in R

I am totally new to mixed-language programming and am having difficulty creating a dll to be called by R.  I found the following small example which supposedly works for the CVF 6.6 compiler online:

SUBROUTINE MYSUB(X,N,XMEAN)
CDEC$ ATTRIBUTES DLLEXPORT,C,REFERENCE,ALIAS:'mysub_' :: MYSUB
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DOUBLE PRECISION X(N)
XMEAN=0D0
DO 10 J=1,N
XMEAN=XMEAN+X(J)
10 CONTINUE
XMEAN=XMEAN/N
RETURN
END

When I try to load the dll in R using dyn.load(), I receive the following error message (I replaced the long path with <file> in the message):

Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared object '<file>':
  LoadLibrary failure:  %1 is not a valid Win32 application.
nd.

I am using XE 12.1 with the Visual Studio shell and R 2.15.1.  Are there other compiler directives or Project settings I shoudl experiment with?

Many thanks!
Jeff
>

3 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Please state how you compiled and linked the DLL. Is your installed R 32-bit or 64-bit?

I should have thought of that; many thanks! The error message was apparently caused by trying to load a 32 bit dll during a 64 bit R session. Like I mentioned, this is my first experience with a mixed language application.

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi