Search code examples
dllr-package

'DLL not found' when building my own R package


I'm attempting to build a CRAN package and I'm getting a strange error when I try to 'Check' my package in RStudio, here is the message:

==> devtools::check(document = FALSE)

-- Building ----------------------------------------------------------------------- TDAInference --
Setting env vars:
* CFLAGS    : -Wall -pedantic -fdiagnostics-color=always
* CXXFLAGS  : -Wall -pedantic -fdiagnostics-color=always
* CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
* CXX14FLAGS: -Wall -pedantic -fdiagnostics-color=always
* CXX17FLAGS: -Wall -pedantic -fdiagnostics-color=always
* CXX20FLAGS: -Wall -pedantic -fdiagnostics-color=always
---------------------------------------------------------------------------------------------------
v  checking for file 'C:\Users\User\Documents\TDAInference/DESCRIPTION' ...
-  preparing 'TDAInference':
v  checking DESCRIPTION meta-information ... 
-  installing the package to build vignettes
         -----------------------------------
-  installing *source* package 'TDAInference' ...
   ** using staged installation
   ** R
   ** byte-compile and prepare package for lazy loading
   ** help
   *** installing help indices
     converting help for package 'TDAInference'
       finding HTML links ... done
       TDAInference                            html  
       diagram_distance                        html  
       diagram_to_df                           html  
       loss                                    html  
       permutation_test                        html  
   ** building package indices
   ** installing vignettes
   ** testing if installed package can be loaded from temporary location
   Error: package or namespace load failed for 'TDAInference' in library.dynam(lib, package, package.lib):
    DLL 'TDAInference' not found: maybe not installed for this architecture?

Has anyone had a similar problem before? Any suggestions of fixes this would be much appreciated!!


Solution

  • Posting because I lost half a day on this ^^'

    I had a similar issue because I removed all my c++ code. However, I had remove the Rcpp import/dpends in my DESCRIPTION file, but that just added the error of a missing dependency in that file... After finding this page, I grep "Rcpp" to see where the hell it was left in and realized that I still had the [packagename]-package.Rfile ^^' which contained:

    ## usethis namespace: start
    #' @importFrom Rcpp sourceCpp
    #' @useDynLib [packagename], .registration = TRUE
    ## usethis namespace: end
    NULL
    

    So yeah, if you don't have c++ code/removed it, make sure your package structure matches ^^'