From murdoch.duncan at gmail.com  Thu Apr 11 00:18:06 2013
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Wed, 10 Apr 2013 18:18:06 -0400
Subject: [Rd] question re: error message --- package error:
 "functionName" not resolved from current namespace
In-Reply-To: <CABWzF4Xn165QfDWvOvXj6FCmXjBSP0bGmVv8gkokTWM=7E+w_g@mail.gmail.com>
References: <CABWzF4XhbD_LGy0UeVSiLd-cHbbvH9z+QTMrRQD1_PMvZv-=6w@mail.gmail.com>
	<CC350C70-2837-4160-B8EF-F391188D4667@r-project.org>
	<CABWzF4XiwH5=U=Bx9yb4V=Cwu+K38QmEONJ0mMVcwYycdXKyjw@mail.gmail.com>
	<5165C357.2000204@gmail.com>
	<CABWzF4Xn165QfDWvOvXj6FCmXjBSP0bGmVv8gkokTWM=7E+w_g@mail.gmail.com>
Message-ID: <5165E51E.9020805@gmail.com>

On 13-04-10 5:35 PM, brian avants wrote:
> Thank you for the advice - the function formed like this:
>
> antsImageRead <- function( filename , dimension , pixeltype = "float" )
> {
>       rval <- (.Call("antsImageRead", filename, pixeltype, dimension))
>       return(rval)
> }
>
> worked up to R 2.15.x  but fails in R 3.0.x
>
> if i include the PACKAGE = 'whatever' , in the .Call above, as here:
>
> antsImageRead <- function( filename , dimension , pixeltype = "float" )
> {
>       rval <- (.Call("antsImageRead", filename, pixeltype, dimension,
> PACKAGE="ANTsR"))
>       return(rval)
> }
>
> then it fails in both 2.15.x and 3.0.x ....
>
> if i source the file
>
> source("ANTsR/R/antsImageRead.R")
>
> after loading the library, then it works fine in 3.0.x without the
> direct call to PACKAGE=ANTsR.
>
> anyway - i hope this clarifies things a bit -
>
> does anyone know of something that might have changed between 2.x and
> 3.x that would relate to this issue?

If you can build a Windows binary or a MacOSX binary of the package, or 
a tarball that the standard tools can install, I'll take a look.

Duncan Murdoch

>
>
>
>
>
> brian
>
>
>
>
> On Wed, Apr 10, 2013 at 3:53 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com <mailto:murdoch.duncan at gmail.com>> wrote:
>
>     On 10/04/2013 2:25 PM, brian avants wrote:
>
>         hi simon
>
>         thank you for your questions ---- answers here:
>
>         I won't answer your question directly but some suggestions:
>          > a) does adding PACKAGE="ANTsR" to .Call change anything? (It
>         should really
>          > be there if you are using strings as names)
>          >
>
>         this does change things .... for instance, this works:
>
>         library(ANTsR)
>         filename<-getANTsRData('r16')
>         .Call("antsImageRead", filename,'double',2) #  Succeeds!
>         .Call("antsImageRead", filename,'double',2,PACKAGE=__ANTsR) #
>           Fails!
>         # Error in .Call("antsImageRead", filename, "double", 2, PACKAGE
>         = "ANTsR")
>         :
>         #  "antsImageRead" not available for .Call() for package "ANTsR"
>
>
>     That makes it look as though it is finding that entry point
>     somewhere other than in the ANTsR.{so|dll} file installed with the
>     package.
>
>
>         the problem is when we call this function:
>
>         antsImageRead <- function( filename , dimension , pixeltype =
>         "float" )
>         {
>               rval <- (.Call("antsImageRead", filename, pixeltype,
>         dimension))
>               return(rval)
>         }
>
>
>     That's the one where you should be using the PACKAGE declaration.
>
>
>
>         the we get the error   antsImageRead not resolved from current
>         namespace ,
>         e.g.:
>
>          > antsImageRead(filename,2)
>         Error in .Call("antsImageRead", filename, pixeltype, dimension) :
>             "antsImageRead" not resolved from current namespace (ANTsR)
>          >
>
>
>         b) you may want to consider use the more efficient registration
>         - either
>          > explicit or in NAMESPACE - so in your case you could use
>          > NAMESPACE: useDynLib(ANTsR, antsImageRead, ...)
>          > foo.R: .Call(antsImageRead, ...)
>          >
>
>         yes - we have all of our shared libraries registered in the
>         NAMESPACE file
>         e.g.
>
>         useDynLib(libRantsImageRead)
>
>
>     But this doesn't register the entry point.  List it explicitly, and
>     it will create an object called antsImageRead in the package
>     namespace that has entry point information.
>
>     Duncan Murdoch
>
>
>         etcetera ....
>
>
>                  [[alternative HTML version deleted]]
>
>         ________________________________________________
>         R-devel at r-project.org <mailto:R-devel at r-project.org> mailing list
>         https://stat.ethz.ch/mailman/__listinfo/r-devel
>         <https://stat.ethz.ch/mailman/listinfo/r-devel>
>
>
>



[Rd] question re: error message --- package error: "functionName" not resolved from current namespace
Duncan Murdoch