[R] problem with Rcmd check and fortran95, makefile

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Aug 19 17:05:10 CEST 2006

First, this is off-topic for R-help (see the posting guide, including the 
non-use of HTML, please).

Second, the appropriate list needs to see exactly what the output was when 
you did this. Remember R CMD SHLIB is a *make* facility, and quite 
possibly the objects were not remade after changes.

And yes, R CMD INSTALL does more than your commands -- as you have the 
sources you can take a look, or even see what the output says.
Here is a simple F95 example (using gcc pre-4.2.0)

---------- Making package testf95 ------------
  adding build stamp to DESCRIPTION
  making DLL ...
"c:/MinGW/bin/gfortran" -O3  -c cos90.f95 -o cos90.o
windres --include-dir d:/R/svn/trunk/include  -i testf95_res.rc -o 
"c:/MinGW/bin/gfortran" -shared -s  -o testf95.dll testf95.def cos90.o 
testf95_res.o  -Ld:/R/svn/trunk/bin   -lR

Note the extras, including a .def file.

If you use R 2.3.1 patched or R-devel you just don't need a Makefile and 
you can use standard Fortran 9X.

On Sat, 19 Aug 2006, data-ploner Meinhard Ploner wrote:

> Hi all,
> I have Win XP and R 2.3.1 on my notebook. I would like to write a package which includes some Fortran 95 code. Interestingly, if  I compile and link the simple file test90.f90 directly with
> g95 -c test90.f90
> g95 -shared -o test90.dll test90.o
> then PE Viewer ( a dll viewer) shows me the right functions in the export table, hence I can use the dll in R. But as it should become part of a package I wrote the simple src/Makefile
> F95=g95
> prog: test90.f90
>  $(F95) -shared -o test90.dll test90.o
> test90.f90: test90.f90
>  $(F95) -c test90.f90
> which looks totally equal to the 2 commands above. If I run now 
> Rcmd check --no-latex test90
> Rcmd install test90
> then test90.dll is made but the export table is empty and therefore in R the functions cannot be loaded.
> Any idea? Can it be that Rcmd gives further flags to the compiler/linker?
> Any hints appreciated
> Meinhard Ploner
> South Tyrol (Italy)
> PS The fortran file is simply:
> !DEC$ ATTRIBUTES DLLEXPORT :: blabla    ### without this line the prob is the same :-(
> A=A+1

You could use --export-all-symbols

> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

More information about the R-help mailing list