Dear all, After reading the manuals (especially R-exts) I haven't found an answer to the following question yet. I was compiling someone else's Fortran routines to make them available with R. Hear, I should not that I don't know anything about Fortran, and I only tried to built a shared library. Linux being my platform of choice when developing for R, I first got everything done there, using R CMD COMPILE, and R CMD SHLIB. Since g77 complained about the Fortran Codes indentation style, I assumed (after reading g77's manpage) that the Fortran code is given in free-form dialect. Therefore, I added a line PKG_FFLAGS+= -ffree-form to Makevars. Compilation and building went fine and I successfully accessed the routines using dyn.load and .Fortran. My colleague, who wanted this done, runs R under windows. So I learnt how to build a package under windows (readme.packages is a great guide!), and it went all smoothly, except: option -free-form no longer was passed to g77 (from Rtools), which caused compilation to fail. Renaming Makevars to Makevars.win did not help. Investigating this in more detail, I found that MakeDLL contains the line <snip> FFLAGS=-O2 $(DEBUGFLAG) <snip> so PKG_FFLAGS weren't used at all. Changing this line to <snip> FFLAGS=$(PKG_FFLAGS) -O2 $(DEBUGFLAG) <snip> resolved the problem, however. I subsequently was again able to access the routines of the built library. My question now is: is this behaviour intended, and, if so, why? I am curious only because I might want to make this package freely available, and wouldn't like to ask people to change MakeDLL which I assume was written that way for good reasons. If the change in MakeDLL is not necessary, how do I then pass a compiler option to g77? Any comments and suggestions are very welcome. I hope my minor knowledge has not raised problems to far off-topic. Thanks in advance for your time and help. Best wishes Thomas ---> version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 7.1 year 2003 month 06 day 16 language R --- Thomas Hotz Research Associate in Medical Statistics University of Leicester United Kingdom Department of Epidemiology and Public Health 22-28 Princess Road West Leicester LE1 6TP Tel +44 116 252-5410 Fax +44 116 252-5423 Division of Medicine for the Elderly Department of Medicine The Glenfield Hospital Leicester LE3 9QP Tel +44 116 256-3643 Fax +44 116 232-2976
On Thu, 3 Jul 2003, Hotz, T. wrote:> Dear all, > > After reading the manuals (especially R-exts) I haven't found > an answer to the following question yet. > > I was compiling someone else's Fortran routines to make them > available with R. Hear, I should not that I don't know anything > about Fortran, and I only tried to built a shared library. > > Linux being my platform of choice when developing for R, I first > got everything done there, using R CMD COMPILE, and R CMD SHLIB. > Since g77 complained about the Fortran Codes indentation style, > I assumed (after reading g77's manpage) that the Fortran code is > given in free-form dialect. Therefore, I added a line > PKG_FFLAGS+= -ffree-form to Makevars. Compilation and building > went fine and I successfully accessed the routines using dyn.load > and .Fortran. > > My colleague, who wanted this done, runs R under windows. So I > learnt how to build a package under windows (readme.packages is a > great guide!), and it went all smoothly, except: option -free-form > no longer was passed to g77 (from Rtools), which caused compilation > to fail. Renaming Makevars to Makevars.win did not help. > > Investigating this in more detail, I found that MakeDLL contains > the line > <snip> > FFLAGS=-O2 $(DEBUGFLAG) > <snip> > so PKG_FFLAGS weren't used at all. Changing this line to > <snip> > FFLAGS=$(PKG_FFLAGS) -O2 $(DEBUGFLAG) > <snip> > resolved the problem, however. I subsequently was again able to access > the routines of the built library. > > My question now is: is this behaviour intended, and, if so, why? I am > curious only because I might want to make this package freely > available, and wouldn't like to ask people to change MakeDLL which I > assume was written that way for good reasons. If the change in > MakeDLL is not necessary, how do I then pass a compiler option to g77? > > Any comments and suggestions are very welcome. I hope my minor > knowledge has not raised problems to far off-topic. Thanks in advance > for your time and help.Why no just transform the Fortran to legal Fortran? You can't assume that your users are going to be using gcc (and from your comments I gather you are intending to distribute this). PKG_FFLAGS has never been implemented on Windows, because we have never seen a need for it. I have just added it to the development version. Nevertheless, it will be hard to find compiler-independent settings and I actually don't know of any possibilities. -- Brian D. Ripley, ripley@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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Reasonably Related Threads
- getting the name of a single object in R for debugging output
- [LLVMdev] [PATCH] Implement dbgs()
- Error when creating layouts with partly filled pages within lattice
- Is it possible to separate two independent components from arandom variable?
- Makevars, PKG_CFLAGS, ...