''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 1:[1]

I figured out the problem. Basically I was trying to borrow file structure from another package which included C code. Seeing as my package has no C code I had some extra lines of code in my Description file (in particular, the useDynLib function). Once I removed that line everything worked perfectly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shaelebrown