0

I am using Rcpp for speeding-up for loops in my package functions. Chapter 15 in R Packages book says:

Whenever you use C++ code in your package, you need to clean up after yourself when your package is unloaded. Do this by writing a .onUnload() function that unloads the DLL:

.onUnload <- function (libpath) {
  library.dynam.unload("mypackage", libpath)
}

So, I created a file unload.R in the R folder within my package folder and put the above code in it. But now I am getting the following warnings:

> checking whether the namespace can be unloaded cleanly ... WARNING
  ---- unloading
  Warning message:
  .onUnload failed in unloadNamespace() for 'carfollowingmodels', details:
    call: library.dynam.unload("mypackage", libpath)
    error: DLL 'mypackage.dll' was not loaded 

> checking whether the namespace can be unloaded cleanly ... WARNING
  ---- unloading
  Warning message:
  .onUnload failed in unloadNamespace() for 'carfollowingmodels', details:
    call: library.dynam.unload("mypackage", libpath)
    error: DLL 'mypackage.dll' was not loaded 

> checking compiled code ... NOTE
  Note: information on .o files for i386 is not available
  Note: information on .o files for x64 is not available
  File 'C:/Users/umair/AppData/Local/Temp/RtmpiWZMKo/carfollowingmodels.Rcheck/carfollowingmodels/libs/i386/carfollowingmodels.dll':
    Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran)
    Found 'exit', possibly from 'exit' (C), 'stop' (Fortran)
    Found 'printf', possibly from 'printf' (C)
  File 'C:/Users/umair/AppData/Local/Temp/RtmpiWZMKo/carfollowingmodels.Rcheck/carfollowingmodels/libs/x64/carfollowingmodels.dll':
    Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran)
    Found 'exit', possibly from 'exit' (C), 'stop' (Fortran)
    Found 'printf', possibly from 'printf' (C)
  
  Compiled code should not call entry points which might terminate R nor
  write to stdout/stderr instead of to the console, nor use Fortran I/O
  nor system RNGs. The detected symbols are linked into the code but
  might come from libraries and not actually be called.
  
  See 'Writing portable packages' in the 'Writing R Extensions' manual.

0 errors √ | 2 warnings x | 1 note x 

What am I missing here? Note that if I don't use the unload.R file, I don't get any warnings. But still get the note.

umair durrani
  • 5,597
  • 8
  • 45
  • 85
  • 2
    Replace "mypackage.dll" with the name of your package, lol – Hong Ooi Apr 25 '21 at 19:48
  • 1
    I presume you are aware that you have other critical flaws there (`abort` or `exit` or `printf`) you need to take care of. And, if I may, _R Packages_ is not normative. What matters for CRAN is what is described in _Writing R Extensions_ and in the _CRAN Repository Policy_. Removing shared libraries is entirely optional; I rarely do it. In any event, @HongOoi is spot on: you have a simply copy-and-paste-oh there. – Dirk Eddelbuettel Apr 25 '21 at 19:51
  • HongOoi, Oh. Thank you, this was embarrassing :). @Dirk, I am not sure how to address them. I searched and found [this question](https://stackoverflow.com/questions/64402688/information-on-o-files-for-x64-is-not-available-note-on-r-package-checks-using). The answer suggests that it is a Windows problem. Please let me know if that is not the case. – umair durrani Apr 25 '21 at 19:55
  • 1
    You can *easily* convince yourself that what you just said is wrong. Just create a one-function package and put `exit()` or `abort()` or `printf()` in there: it is 100% orthogonal to the OS, and it is a question I have in one way or form answered dozens of time here or on the list. The use of the forbidden functions _may_ come from libraries you use. – Dirk Eddelbuettel Apr 25 '21 at 19:57
  • @DirkEddelbuettel, thanks for your comments. The only library I am using is `cmath` in the c++ file. I am not using any library in R except `base`. So, I am not sure what might be causing this note. Perhaps, something in my function, but the outputs I get are as expected. Is there a way to check where exactly are these forbidden functions used? – umair durrani Apr 25 '21 at 20:07

0 Answers0