Hi, I would like to use a Fortran subroutine in R. I have checked the R docs and Newsletter, but..., I am unable to load an object file into R. The steps I have taken are (on Debian Linux/recent Intel-type chip ): 1. g77 -c hello.f to create hello.o 2. mymachine> R to start R 3. > dyn.load("hello.o") at which point I am getting the error msg: Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library "/home/hawkins/Rfortran/hello.o": /home/hawkins/Rfortran/hello.o: ELF file's phentsize not the expected size Can anyone (please) correct my procedure, offer a suggestion? thanks, Natalie Hawkins -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
See `Writing R Extensions' for the information. R CMD SHLIB hello.f> dyn.load("hello.so")might be what you need. dyn.load in R loads shared libraries (on Linux), not .o objects. The error message does say your hello.o is not a valid shared library. Looks like the help page for dyn.load needs a cross-reference to SHLIB. On Tue, 24 Jul 2001, Natalie Hawkins wrote:> > Hi, > > I would like to use a Fortran subroutine in R. I have checked the R > docs and Newsletter, > but..., I am unable to load an object file into R. > > The steps I have taken are (on Debian Linux/recent Intel-type chip ): > > 1. g77 -c hello.f > to create hello.o > > 2. mymachine> R > to start R > > 3. > dyn.load("hello.o") > at which point I am getting the error msg: > > Error in dyn.load(x, as.logical(local), as.logical(now)) : > unable to load shared library "/home/hawkins/Rfortran/hello.o": > /home/hawkins/Rfortran/hello.o: ELF file's phentsize not the expected > size > > Can anyone (please) correct my procedure, offer a suggestion? > > thanks, > Natalie Hawkins-- Brian D. Ripley, ripley at stats.ox.ac.uk 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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "Natalie" == Natalie Hawkins <hawkins at scharp.org> writes:Natalie> I would like to use a Fortran subroutine in R. I have checked Natalie> the R docs and Newsletter, but..., I am unable to load an Natalie> object file into R. Natalie> The steps I have taken are (on Debian Linux/recent Intel-type Natalie> chip ): Natalie> 1. g77 -c hello.f Natalie> to create hello.o You should say R CMD SHLIB hello.f which will create hello.so in one step. Alternatively R CMD COMPILE hello.f R CMD SHLIB hello.o should do the same in two steps (useful if there are several source files) Natalie> 2. mymachine> R Natalie> to start R Natalie> 3. > dyn.load("hello.o") which would then be dyn.load("hello.so") and I actually always use an explicit path Natalie> at which point I am getting the error msg: Natalie> Error in dyn.load(x, as.logical(local), as.logical(now)) : Natalie> unable to load shared library "/home/hawkins/Rfortran/hello.o": Natalie> /home/hawkins/Rfortran/hello.o: ELF file's phentsize not the Natalie> expected size Natalie> Can anyone (please) correct my procedure, offer a suggestion? In R, try ?dyn.load and ?SHLIB (and yes, the next version of R will have a SEEALSO link from dyn.load to SHLIB). Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._