Home > OS >  Shared .so file not found when loading R package with Rcpp component Linux systems
Shared .so file not found when loading R package with Rcpp component Linux systems

Time:11-26

I apologize in advance if this question has been asked before but I haven't been able to find a suitable answer after days of searching.

I have a package that has a couple of small functions written in C using Rcpp (package can be found here). When trying to install this package on Linux systems (both local install and via Github Actions - Ubuntu 18.04, 20.04) the compiling procedure was successful but R cannot load the package because an .so file was not found. Mac and Windows systems work fine and there were no R CMD CHECK issues when tested on these systems.

I was wondering if there is any way to solve this issue? I was thinking of adding something in .Makevars but I don't know what to add.

Thank you so much in advance.

─  installing *source* package ‘CBEA’ ...
   ** using staged installation
   ** libs
   g   -std=gnu  11 -I"/usr/local/lib/R/include" -DNDEBUG  -I'/__w/_temp/Library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -Wall -pedantic -c RcppExports.cpp -o RcppExports.o
   g   -std=gnu  11 -I"/usr/local/lib/R/include" -DNDEBUG  -I'/__w/_temp/Library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -Wall -pedantic -c gmeans.cpp -o gmeans.o
   g   -std=gnu  11 -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o CBEA.so RcppExports.o gmeans.o -L/usr/local/lib/R/lib -lR
   installing to /tmp/RtmpwFufM0/Rinst8982598ffd0c/00LOCK-CBEA/00new/CBEA/libs
   ** R
   ** data
   ** inst
   ** byte-compile and prepare package for lazy loading
   ** help
   *** installing help indices
   *** copying figures
   ** building package indices
   ** installing vignettes
   ** testing if installed package can be loaded from temporary location
   Error: package or namespace load failed for ‘CBEA’ in library.dynam(lib, package, package.lib):
    shared object ‘cbea.so’ not found
   Error: loading failed
   Execution halted
   ERROR: loading failed
─  removing ‘/tmp/RtmpwFufM0/Rinst8982598ffd0c/CBEA’

CodePudding user response:

Your (generated) NAMESPACE file has two entries referring to the package:

useDynLib(CBEA, .registration = TRUE)
useDynLib(cbea, .registration = TRUE)

Remove the second one (i.e. remove whereever you tell roxygen2 to add it, and you will be fine. The rror message you see and quote indicates a case issue as on Linux, cbea.so is different from CBEA.so (whereas macOS and Windows let you get away with it).

  • Related