I am new to R package development. I am working on a package that has in
its src folder  one (prime) cpp file and some helper cpp (X.Cpp, Y.Cpp) and
one c file (Z.C) and their header files (X.h, Y.h and Z.h)

I am getting the following error when I do 'Build & Reload' in Rstudio.

Error in dyn.load(dllfile) :
  unable to load shared object '/Users/abcd/BART/bart_pkg1/src/bartpkg.so':
  dlopen(/Users/abcd/BART/bart_pkg1/src/bartpkg.so, 6): Symbol not found:
  Referenced from: /Users/abcd/BART/bart_pkg1/src/bartpkg.so
  Expected in: flat namespace
 in /Users/abcd/BART/bart_pkg1/src/bartpkg.so
Calls: suppressPackageStartupMessages ... <Anonymous> -> load_all ->
load_dll -> library.dynam2 -> dyn.load
Execution halted

Exited with status 1.


I have followed the basic guidelines to build the package.

The .R file has directive #' @useDynLib bartpkg in the right place.

Also, the prime cpp file has the following tags in the right place.
1. #include <Rcpp.h>
  using namespace Rcpp;
2.  //' @param x A single integer.
     //' @export
     // [[Rcpp::export]]

And my NAMESPACE file shows 'useDynLib(bartpkg)' correctly.

I am able to see the 'bartpkg.so' shared object file in the src directory.

I tried in the terminal this command "c++filt -n _ZN3RNG4nfixElm" and was
able to see that the symbol in the error ' Symbol not found:
__ZN3RNG4nfixElm' is coming from the .C file RNG.C and is because of a
function 'nfix'.

But even if I remove the function 'nfix' or remove the RNG.C file
altogether, the same error ' Symbol not found: __ZN3RNG4nfixElm' comes.

can it  be a flag issue that my compiler is not able to compile the 'C'
I am able to see that all the cpp files generate respective object files,
but I dont see anything like that for the C file.

I am using RStudio is the session info is
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] bartpkg_0.1.0        packrat_0.4.8-1      Rcpp_0.12.8
msm_1.6.4            LaplacesDemon_16.0.1

loaded via a namespace (and not attached):
 [1] roxygen2_5.0.1  lattice_0.20-34 mvtnorm_1.0-5   digest_0.6.10
grid_3.3.1      magrittr_1.5
 [7] stringi_1.1.2   Matrix_1.2-7.1  splines_3.3.1   tools_3.3.1
stringr_1.1.0   survival_2.39-5
[13] parallel_3.3.1  rsconnect_0.5   inline_0.3.14   expm_0.999-0

I am stuck at this problem for weeks now.
Any help would be highly appreciated.

Thank you.


        [[alternative HTML version deleted]]

R-package-devel@r-project.org mailing list

Reply via email to