Skip to content
Prev 45534 / 63424 Next

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

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.