Hi everyone, I'm a beginner in R and I'm trying to load a .dll file, named dll.dll, that's written in C, into R. It seems to work, now I want to use the functions that are stored in the .dll file and I encounter problems. I've searched for a solution or other method in manuals, here and on google. Would be very thankful if I could get a suggestion of what to use or any idea! My code: setwd("C:/Users/MyUser/R") dyn.load("dll.dll") is.loaded("DLL_FUNK") # For some reason True with capital letters, not in lower case output <- .C("DLL_FUNK", in9 = as.integer(7)) #output # R Crashes before I can write this. # R Crashes # In outdata.txt: "in-value= 139375128" The function should return a number, 1955. But I can't seem to get to that value. What am I doing wrong? Update with code (Fortran runned as C), this is the code in dll.dll: subroutine dll_funk(in9) implicit none !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !*** Declarations: variables, functions !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ integer(4) :: in9 !integer :: in9 ! Definitions of variables in the external function calls !!dec$ attributes c,alias :'dll_funk' :: dll_funk !dec$ attributes dllexport :: dll_funk !dec$ attributes value :: in9 open(194,file='outdata.txt') write(194,*) 'in-value=', in9 ! in9 = 1955 close(194) end subroutine !end function So now when it runs, R crashes but before it writes to my file (outdata.txt) but it't not my number, maybe some kind of address... Another question, do you recommend me to run the code with .C and from C run the Fortran code or is it better to run it with .Fortran with only Fortran code? It seems like .Fortran have problem handling strings, or that's what I understood from: Interface func .C and .Fortran<https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Interface-functions-_002eC-and-_002eFortran> Thanks for your time! Best regards, David [[alternative HTML version deleted]]