An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-devel/attachments/20050928/3a4e228a/attachment.pl
gfortran Makefile for windows
3 messages · Joel Bremson, Brian Ripley
I am unaware that gfortran or gcc4 exist as a MinGW binary for Windows. You mention Cygwin, but that is not a supported platform for R. There is a g95 binary for Windows. You can find how to link on Windows from the sources: most of the rules are in src/gnuwin32/MkRules. I suspect all you need is to set pkgname-DLLLIBS appropriately. I don't see that you need a Makefile: a Makevars file would suffice and avoid your hardcoding so many OS-specific features. In any case it seems to me that in general you need to link against the Fortran libraries: you may get away with it on MacOS, but you will not on Windows. Support for F95 files is planned for R 2.3.0, but depends on being able to differentiate F77 and F95 sources where needed (most platforms). Meanwhile we will try to add an example to the R-admin manual for 2.2.0.
On Wed, 28 Sep 2005, Joel Bremson wrote:
Hi all, (Originally posted to r-help)
Congratulations: you have now read the posting guide and selected an appropriate list! Perhaps soon you will get the part about not sending HTML mail? Seriously, there is a posting guide, and it asks you to do your homework before posting. Please show us the courtesy of doing so.
I'm porting a package that I've worked on for OS X to Windows.
The package is written in F95 so I need to compile it with gfortran
and link it with gcc4.
I've been trying to build an R with gcc4 without luck so far. If there is
a binary of such a thing info would be appreciated.
This package requires a Makefile. My question is, how can I find out
(or what is), the link command?
Here is the OS X Makefile:
RLIB_LOC=${R_HOME}
F90_FILES=\
class_data_frame.f90 \
class_old_dbest.f90 \
class_cm_data.f90 \
class_cm.f90 \
class_bgw.f90 \
class_cm_mle.f90 \
cme.f90
FORTRAN_FILES=\
dgletc.f \
dglfgb.f\
dglfg.f\
dmdc.f\
mecdf.f
%.o: %.f90
gfortran -c -g $<
%.o: %.f
gfortran -c -g $<
bpkg.so: $(F90_FILES:%.f90=%.o) $(FORTRAN_FILES:%.f=%.o)
gcc -Wall -bundle -flat_namespace -undefined suppress -L/sw/lib
-L/usr/local/lib -o $@ $^ \
-L$(RLIB_LOC)/lib -lR
###EOF####
The -L lib dirs are not correct. On a *nix platform I would do something
like this
sh -x R CMD SHLIB ...
to get at the R internal link information but I can't get that to work on
Cygwin.
Regards,
Joel
--
Joel Bremson
Graduate Student
Institute for Transportation Studies - UC Davis
http://etrans.blogspot.com
[[alternative HTML version deleted]]
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
On Wed, 28 Sep 2005, Prof Brian Ripley wrote:
I am unaware that gfortran or gcc4 exist as a MinGW binary for Windows. You mention Cygwin, but that is not a supported platform for R. There is a g95 binary for Windows.
At www.g95.org, but I found no installation instructions relevant to Windows. Some comments at the end of this message. [...]
Support for F95 files is planned for R 2.3.0, but depends on being able to differentiate F77 and F95 sources where needed (most platforms). Meanwhile we will try to add an example to the R-admin manual for 2.2.0.
Here is an example src/Makefile.win for a package called testf95 that uses
F95/F90 only.
% cat testf95/src/Makefile.win
DLLNAME=testf95 # will not be needed in 2.2.0
include $(RHOME)/src/gnuwin32/MkRules
F90SOURCES=$(wildcard -f *.f90)
F95SOURCES=$(wildcard -f *.f95)
OBJS=$(F90SOURCES:.f90=.o) $(F95SOURCES:.f95=.o)
G95=c:/packages/g95/bin/g95
MINGW=c:/packages/gcc-3.4.4/
.SUFFIXES: .f90 .f95
.f90.o:
$(G95) -c $< -o $@
.f95.o:
$(G95) -c $< -o $@
## at least on my setup, G95 is not searching MinGW libs.
DLL=$(G95) -L$(MINGW)/lib
all: $(DLLNAME).dll
## Rules copied from MakeDll
RCNAME=${DLLNAME}_res
RCOBJ=$(RCNAME).o
RESFLAGS=--include-dir $(RHOME)/include
$(DLLNAME)_res.rc:
@PERL5LIB=$(RHOME)/share/perl perl
$(RHOME)/src/gnuwin32/makeDllRes.pl $(DLLNAME) > $@
$(DLLNAME)_res.o: $(DLLNAME)_res.rc $(RHOME)/include/Rversion.h
$(DLLNAME).a: $(OBJS)
$(DLLNAME).dll : $(DLLNAME).a $(RCOBJ)
It works for me, but do be aware that it will depend on the
fine details of how your MinGW/G95 tools are installed. I had to copy
dllcrt2.o from MINGW/lib to
C:/packages/g95/lib/gcc-lib/i686-pc-mingw32/4.0.1 since the paths are
processed after that file. It is probably better to fiddle with the specs
file.
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