From berwin at maths.uwa.edu.au  Sun Jan 22 10:11:23 2006
From: berwin at maths.uwa.edu.au (Berwin A Turlach)
Date: Sun, 22 Jan 2006 17:11:23 +0800
Subject: [Rd] R CMD check, NAMESPACE, import: bad error?
In-Reply-To: <Pine.LNX.4.61.0601200719490.25948@gannet.stats>
References: <m24q3zbu0z.fsf@fhcrc.org>
	<17360.27502.365586.740869@bossiaea.maths.uwa.edu.au>
	<Pine.LNX.4.61.0601200719490.25948@gannet.stats>
Message-ID: <17363.19515.464525.105706@bossiaea.maths.uwa.edu.au>

G'day Brian,

>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

    BDR> We do recommend you try INSTALLing and loading the package
    BDR> before R CMD check.
I have to rely on my memory, but if I remember correctly, installing
and loading the package worked.  It was only when it came to "R CMD
check" that the combination of having a NAMESPACE and no "PACKAGE="
argument in a .Fortran() call made "R CMD check" complain.  (With much
the same complaints that Seth reported).

But now I am utterly confused because I wanted to test if my memory is
correct.  So I went back to the package (called SCSS) with which I
experienced these problems (according to the dates of the files I was
putting that package together around 12 October 2005, which was just
after the release of R 2.2.0 and I believe I was using that version).

After removing the "PACKAGE=" arguments from the .Fortran() calls, the
package installs and loads fine.  But to my utter amazement, "R CMD
check" now works without a problem.  I tried this command with R
2.1.1, R 2.2.0, R 2.2.1 and R 2.3.0 (i.e. R-devel).

What surprised me most, was that all these versions said

* checking foreign function calls ... OK

I thought that this check is supposed to catch missing "PACKAGE="
arguments in .C(), .Fortran() &c calls???

The only explanation I have, is that my Debian linux system was some
time ago upgraded to gcc 4.0.3 and gfortran.  Indeed, running "R CMD
check" with R 2.3.0 produces a 00install.out file in the SCSS.Rcheck
directory that says:

* Installing *source* package 'SCSS' ...
** libs
make[2]: Entering directory `/home/berwin/lang/R/Develop/SCSS/src'
gfortran   -fpic  -g -O2 -c evsp.f -o evsp.o
gfortran   -fpic  -g -O2 -c evsp1d.f -o evsp1d.o
gfortran   -fpic  -g -O2 -c repar.f -o repar.o
gcc -shared -L/usr/local/lib -o SCSS.so evsp.o evsp1d.o repar.o  -lgfortran -lm -lgcc_s 

whereas R 2.1.1, R 2.2.0 and R 2.2.1 issue the following lines during
"R CMD check":

* Installing *source* package 'SCSS' ...
** libs
make[2]: Entering directory `/home/berwin/lang/R/Develop/SCSS/src'
g77   -fPIC  -g -O2 -c evsp.f -o evsp.o
g77   -fPIC  -g -O2 -c evsp1d.f -o evsp1d.o
g77   -fPIC  -g -O2 -c repar.f -o repar.o
gcc -shared -L/usr/local/lib -o SCSS.so evsp.o evsp1d.o repar.o  -L/usr/lib/gcc/i486-linux-gnu/3.4.5 -lg2c -lm -lgcc_s

since those versions of R where compiled and installed while I was
using gcc 3.4 on my machine.  

But on my machine I have now:

[bossiaea:Develop]$ file `which gcc`
/usr/bin/gcc: symbolic link to `gcc-4.0'

I redirected the link to point to gcc-3.4, but I still could not
reproduce the problems that I experienced last October (and which Seth
experienced right now).  Perhaps the problem only occurs with a very
specific version of the gcc compiler??

    >> [...]  My advise would be to check all .C() and .Fortran()
    >> calls in your package and add the "package=" argument if it is
    >> missing.
    BDR> (It had better be PACKAGE= !)
Of course, my bad.

Cheers,

        Berwin



[Rd] R CMD check, NAMESPACE, import: bad error?
Berwin A Turlach