Mstislav Elagin
2006-Oct-09 07:32 UTC
[R] Problem building a DLL from Fortran 90 source under Windows (with solution)
Hi, All, I have come across a problem building a DLL from .f90 source (R 2.3.1, Windows XP). When using the R CMD SHLIB procedure, the DLL itself was being built, but its export table was empty. Among the output from R CMD SHLIB the following message appeared: c:\mingw\bin\nm.exe: 'a.out': No such file The reason is the empty list of dependencies in the pattern rule for DLLs contained in the file MkRules: %.dll: @$(ECHO) EXPORTS > $*.def @$(NM) $^ | $(SED) -n 's/^........ [BCDRT] _/ /p' >> $*.def The dependencies list is constructed in the MakeDll file that contains the following: CFSOURCES=$(wildcard -f *.c *.f *.f90 *.f95) CSOURCES=$(wildcard -f *.c) CXXSOURCES=$(wildcard -f *.cc *.cpp *.C) FSOURCES=$(wildcard -f *.f) FCSOURCES=$(wildcard -f *.f90 *.f95) OBJSA=$(foreach i,$(CSOURCES) $(FSOURCES) $(CXXSOURCES),$(basename $i).o) Observe that the neither CFSOURCES nor FCSOURCES in included in OBJSA, i.e. an object file made from a f90 source never becomes part of dependencies. If I add $(FCSOURCES) to OBJSA, the DLL gets built correctly. I wonder whether there is a reason for not including .f90 (and .f95) sources in the list of dependencies or this can be considered a bug in R. WBR -- Mstislav Elagin
Prof Brian Ripley
2006-Oct-10 08:32 UTC
[R] Problem building a DLL from Fortran 90 source under Windows (with solution)
On Mon, 9 Oct 2006, Mstislav Elagin wrote:> Hi, All, > > I have come across a problem building a DLL from .f90 source (R 2.3.1, > Windows XP). When using the R CMD SHLIB procedure, the DLL itself was > being built, but its export table was empty. > > Among the output from R CMD SHLIB the following message appeared: > > c:\mingw\bin\nm.exe: 'a.out': No such file > > The reason is the empty list of dependencies in the pattern rule for > DLLs contained in the file MkRules: > > %.dll: > @$(ECHO) EXPORTS > $*.def > @$(NM) $^ | $(SED) -n 's/^........ [BCDRT] _/ /p' >> $*.def > > The dependencies list is constructed in the MakeDll file that contains > the following: > > CFSOURCES=$(wildcard -f *.c *.f *.f90 *.f95) > CSOURCES=$(wildcard -f *.c) > CXXSOURCES=$(wildcard -f *.cc *.cpp *.C) > FSOURCES=$(wildcard -f *.f) > FCSOURCES=$(wildcard -f *.f90 *.f95) > OBJSA=$(foreach i,$(CSOURCES) $(FSOURCES) $(CXXSOURCES),$(basename $i).o) > > Observe that the neither CFSOURCES nor FCSOURCES in included in OBJSA, > i.e. an object file made from a f90 source never becomes part of > dependencies. If I add $(FCSOURCES) to OBJSA, the DLL gets built > correctly. > > I wonder whether there is a reason for not including .f90 (and .f95) > sources in the list of dependencies or this can be considered a bug in > R.Please use a current version of R (as the posting guide asks). From the CHANGES file for 2.3.1 patched: Objects from Fortran 9X sources no longer need to be declared to R CMD SHLIB/INSTALL via OBJS in Makevars.win. -- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595