Skip to content

question re: error message --- package error: "functionName" not resolved from current namespace

8 messages · brian avants, Simon Urbanek, Duncan Murdoch +1 more

#
On Apr 10, 2013, at 1:53 PM, brian avants wrote:

            
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)
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, ...)

Cheers,
Simon
#
On 10/04/2013 2:25 PM, brian avants wrote:
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.
That's the one where you should be using the PACKAGE declaration.
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
#
On 13-04-10 5:35 PM, brian avants wrote:
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
#
For what it's worth, the package loads many DLLs in its NAMESPACE via repeated 
calls to useDynLib. antsImageRead is not in the first DLL loaded, and from 
NEWS.Rd, the problem comes from

     o   A foreign function call (.C() etc) in a package without a PACKAGE
	argument will only look in the first DLL specified in the NAMESPACE
	file of the package rather than searching all loaded DLLs.  A few
	packages needed PACKAGE arguments added.

 From ?.Call, 'PACKAGE' is I believe meant to name the DLL (libRantsImageRead in 
this case) rather than the R package.

Some archaeology below.

Martin
On 04/10/2013 02:35 PM, brian avants wrote:
When .Call has a PACKAGE argument, or when R tries to guess the DLL from the 
fact that .Call is from within a NAMESPACE, only one DLL is found (from 
R_FindNativeSymbolFromDLL in main/dotcode.c:1331, which calls getCallingDLLe). 
the function "antsImageRead" is not in the DLL returned by getCallingDLLe, so 
not found.

 > getNativeSymbolInfo("antsImageRead")$package
DLL name: libRantsImageRead
Filename:
 
/home/mtmorgan/R/x86_64-unknown-linux-gnu-library/3.0-2.13/ANTsR/libs/libRantsImageRead.so
Dynamic lookup: TRUE

 > getCallingDLLe(getNamespace("ANTsR"))
DLL name: libRantsRegistration
Filename:
 
/home/mtmorgan/R/x86_64-unknown-linux-gnu-library/3.0-2.13/ANTsR/libs/libRantsRegistration.so
Dynamic lookup: TRUE
from the command line, we are not in a NAMESPACE so R uses R_FindSymbol at 
dotcode.c:259; this performs a more general search and finds the appropriate symbol.

The change was somewhere around

------------------------------------------------------------------------
r60607 | ripley | 2012-09-07 10:56:35 -0700 (Fri, 07 Sep 2012) | 1 line
Changed paths:
    M /trunk/doc/NEWS.Rd
    M /trunk/src/main/dotcode.c

confine .C etc in a package to the registered DLL.