51

How to avoid the following NOTE that is appearing in R CMD check with the new R development version ( R Under development (unstable) (2017-02-15 r72179))?

• checking for unstated dependencies in examples ... OK
• checking line endings in C/C++/Fortran sources/headers ... OK
• checking compiled code ... NOTE
File ‘pkgname/libs/pkgname.so’:
  Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’

It is good practice to register native routines and to disable symbol
search.

For example in Hmisc

Crops
  • 5,024
  • 5
  • 38
  • 65

3 Answers3

48

The message is somewhat arcane. I looked around also in other packages and I found that the useDynLib(packagename) in the NAMESPACE file was replaced by useDynLib(packagename, .registration = TRUE).

In addition, I added a .c file, named registerDynamicSymbol in the src/ directory with the following code:

// RegisteringDynamic Symbols

#include <R.h>
#include <Rinternals.h>
#include <R_ext/Rdynload.h>

void R_init_markovchain(DllInfo* info) {
  R_registerRoutines(info, NULL, NULL, NULL, NULL);
  R_useDynamicSymbols(info, TRUE);
}

I took this suggestion from GitHub Rcpp. The canonical reference is in Writing R Extensions

Also R Devel Mailinglist provided supplementary infos.

UPDATE

The most direct straightforward approach is:

  1. use the current R Development Version (that will eventually become 3.4)
  2. Run the tools::package_native_routine_registration_skeleton(".") and copy and paste the full output in a packagename_init.c file to be put in src/
  3. update NAMESPACE, verifying that useDynLib(packagename, .registration = TRUE)
  4. If necessary, replace the exportPattern with export( list of object to be exported )

UPDATE 18th July

As noted by @Symbolix using the most recent version of R and RStudio's devtools the point 2. (init.c files) appears handled by either devtools (using RStudio check digit) or tools packages.

Giorgio Spedicato
  • 2,413
  • 3
  • 31
  • 45
  • 1
    I was am using `@useDynLib pkg fun` in the `devtools` package for registering C functions. [But it seems there is more to it.](https://www.r-project.org/doc/Rnews/Rnews_2001-3.pdf#section*.51) – Crops Feb 20 '17 at 09:35
  • 1
    I had the same problem - I used your suggestions and this is the result: Found no call to: 'R_registerRoutines' Which means it found the R_useDynamicSymbols statement. But I am wondering now, why the registerRoutines error did not disappear as well... – Steffen Moritz Feb 23 '17 at 03:11
  • 1
    Shouldn't the fact that I am making my .C call with funtionname instead of "functionName" and without package = "mypackage" indicate, that the registration actually worked...? – Steffen Moritz Feb 23 '17 at 05:12
  • 3
    This was extremely helpful. The only problem I encountered was that devtools::release() wanted to re-write the NAMESPACE file during pre-release check, so losing the useDynLib edit. Setting check=FALSE when calling the release function fixed that. – michael Apr 06 '17 at 00:22
  • 2
    I only needed steps 1 & 2 when building on R 3.4.0 (and also using NAMESPACE generated from roxygen) – SymbolixAU Apr 26 '17 at 01:27
  • @SymbolixAU, possibly the released R 3.4 has changed since dev version – Giorgio Spedicato Apr 26 '17 at 09:01
  • 11
    For those working with roxygen, change your `@useDynLib packagename` to `@useDynLib packagename, .registration = TRUE`, so you don't need to manually edit the NAMESPACE file. – const-ae May 07 '17 at 20:42
  • 1
    As of Rcpp 1.12.11 and R 3.4.0 I think this is all handled for you. – SymbolixAU Jul 04 '17 at 05:13
  • @SymbolixAU nope, just had the issue on my package with these versions :-( – pommedeterresautee Jul 04 '17 at 08:40
  • 2
    For further ref, I got then error message: failed to assign RegisteredNativeSymbol for * to * since * is already defined in the * namespace. Just meant I had c routine and R wrapper with same name, so had to rename the C routine to different name, re-run process, and was good. – Matifou Aug 30 '17 at 02:58
  • Make sure to indeed use R devel or R CMD; using e.g. devtools::check may still tell you "Found no calls to:..." even to you have added the above. See also http://r.789695.n4.nabble.com/Problem-with-R-registerRoutines-td4748507.html – martin Mar 15 '19 at 14:38
  • If you get the error "no native symbols were extracted", try character_only: `tools::package_native_routine_registration_skeleton(".", "src/init.c", character_only=FALSE)` – Berry Boessenkool May 21 '19 at 20:41
  • 1
    I asked the R team, and they said that it is safe to ignore this note. (R version 4.1.2) – A Fog Oct 18 '22 at 11:12
5

I ran into a persistent issue with a Windows build package. (.dll instead of .so)

The accepted answer above should also resolve this issue for Windows, but if it does not resolve it. Make sure that objdump.exe is pointing the appropriate arch. i.e. .../Mingw_64/bin/objdump.exe. This can be checked from a command prompt with which objdump.exe. Somehow a 32-bit objdump.exe found its way into a higher priority position in my path. This arch mismatch will produce a File format not recognized error.

0

First I did exactly what Giorgio Spedicato says. But still got NOTE warnings. Finally I got problem solved by doing this:

Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\RTools40", "C:\RTools40\mingw64\bin", sep = ";"))

Have to add mingw64\bin to PATH because that's where objdump.exe is located