I’m using the OpenBLAS library for my Rcpp codes, but some scripts fail to compile while others succeed.
The issue seems to be related to matrix multiplication using the * operator in Armadillo, as scripts without this operation compile successfully.
My Makevars.win file contains:
PKG_LIBS = -L/C:/OpenBLAS/lib -lopenblas
PKG_CPPFLAGS = -I /C:/OpenBLAS/include
For scripts that successfully complied, sourceCpp returns:
> sourceCpp("./SpatialEffect/src/calculate_tau.cpp",verbose=1)
Generated extern "C" functions
--------------------------------------------------------
#include <Rcpp.h>
#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif
// calculate_tau
Rcpp::List calculate_tau(arma::mat Y, arma::mat Zdata);
RcppExport SEXP sourceCpp_1_calculate_tau(SEXP YSEXP, SEXP ZdataSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type Y(YSEXP);
Rcpp::traits::input_parameter< arma::mat >::type Zdata(ZdataSEXP);
rcpp_result_gen = Rcpp::wrap(calculate_tau(Y, Zdata));
return rcpp_result_gen;
END_RCPP
}
Generated R functions
-------------------------------------------------------
`.sourceCpp_1_DLLInfo` <- dyn.load('C:/Users/haogechang/AppData/Local/Temp/RtmpmIucyH/sourceCpp-x86_64-w64-mingw32-1.0.11/sourcecpp_ad2843c34c6c/sourceCpp_2.dll')
calculate_tau <- Rcpp:::sourceCppFunction(function(Y, Zdata) {}, FALSE, `.sourceCpp_1_DLLInfo`, 'sourceCpp_1_calculate_tau')
rm(`.sourceCpp_1_DLLInfo`)
Building shared library
--------------------------------------------------------
DIR: C:/Users/haogechang/AppData/Local/Temp/RtmpmIucyH/sourceCpp-x86_64-w64-mingw32-1.0.11/sourcecpp_ad2843c34c6c
C:/PROGRA~1/R/R-43~1.1/bin/x64/R CMD SHLIB -o "sourceCpp_2.dll" "calculate_tau.cpp"
using C++ compiler: 'G__~1.EXE (GCC) 12.3.0'
g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -IC:/OpenBLAS/include -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/Rcpp/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/RcppArmadillo/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/raster/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/fields/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/ri/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/geosphere/include" -I"C:/Users/HAOGEC~1/ONEDRI~1/Desktop/SPATIA~2/SPATIA~2/SPATIA~1/src" -I"C:/Users/haogechang/OneDrive - Microsoft/Desktop/SpatialReplication/SpatialReplication/SpatialEffect/inst/include" -I"C:/RBuildTools/4.3/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c calculate_tau.cpp -o calculate_tau.o
g++ -std=gnu++17 -shared -s -static-libgcc -o sourceCpp_2.dll tmp.def calculate_tau.o -LC:/OpenBLAS/lib -lopenblas -LC:/RBuildTools/4.3/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/RBuildTools/4.3/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-43~1.1/bin/x64 -lR
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/haogechang/OneDrive - Microsoft/Desktop/SpatialReplication/SpatialReplication/SpatialEffect/src/../inst/include": The system cannot find the path specified
For the script that fails to compile, it looks like
> sourceCpp("./SpatialEffect/src/effect_nonmo.cpp",verbose=1)
Generated extern "C" functions
--------------------------------------------------------
#include <Rcpp.h>
#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif
// nonmonoeffect_c
NumericVector nonmonoeffect_c(NumericVector d, double sh, double sc, double a);
RcppExport SEXP sourceCpp_3_nonmonoeffect_c(SEXP dSEXP, SEXP shSEXP, SEXP scSEXP, SEXP aSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericVector >::type d(dSEXP);
Rcpp::traits::input_parameter< double >::type sh(shSEXP);
Rcpp::traits::input_parameter< double >::type sc(scSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
rcpp_result_gen = Rcpp::wrap(nonmonoeffect_c(d, sh, sc, a));
return rcpp_result_gen;
END_RCPP
}
// effect_nonmo1
Rcpp::List effect_nonmo1(arma::colvec Y0, NumericMatrix dist, arma::mat Zdata, arma::colvec alpha, double effect, double sh, double sc, double a);
RcppExport SEXP sourceCpp_3_effect_nonmo1(SEXP Y0SEXP, SEXP distSEXP, SEXP ZdataSEXP, SEXP alphaSEXP, SEXP effectSEXP, SEXP shSEXP, SEXP scSEXP, SEXP aSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::colvec >::type Y0(Y0SEXP);
Rcpp::traits::input_parameter< NumericMatrix >::type dist(distSEXP);
Rcpp::traits::input_parameter< arma::mat >::type Zdata(ZdataSEXP);
Rcpp::traits::input_parameter< arma::colvec >::type alpha(alphaSEXP);
Rcpp::traits::input_parameter< double >::type effect(effectSEXP);
Rcpp::traits::input_parameter< double >::type sh(shSEXP);
Rcpp::traits::input_parameter< double >::type sc(scSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
rcpp_result_gen = Rcpp::wrap(effect_nonmo1(Y0, dist, Zdata, alpha, effect, sh, sc, a));
return rcpp_result_gen;
END_RCPP
}
Generated R functions
-------------------------------------------------------
`.sourceCpp_3_DLLInfo` <- dyn.load('C:/Users/haogechang/AppData/Local/Temp/RtmpmIucyH/sourceCpp-x86_64-w64-mingw32-1.0.11/sourcecpp_ad281b253d0e/sourceCpp_4.dll')
nonmonoeffect_c <- Rcpp:::sourceCppFunction(function(d, sh, sc, a) {}, FALSE, `.sourceCpp_3_DLLInfo`, 'sourceCpp_3_nonmonoeffect_c')
effect_nonmo1 <- Rcpp:::sourceCppFunction(function(Y0, dist, Zdata, alpha, effect, sh, sc, a) {}, FALSE, `.sourceCpp_3_DLLInfo`, 'sourceCpp_3_effect_nonmo1')
rm(`.sourceCpp_3_DLLInfo`)
Building shared library
--------------------------------------------------------
DIR: C:/Users/haogechang/AppData/Local/Temp/RtmpmIucyH/sourceCpp-x86_64-w64-mingw32-1.0.11/sourcecpp_ad281b253d0e
C:/PROGRA~1/R/R-43~1.1/bin/x64/R CMD SHLIB -o "sourceCpp_4.dll" "effect_nonmo.cpp"
using C++ compiler: 'G__~1.EXE (GCC) 12.3.0'
g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -IC:/OpenBLAS/include -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/Rcpp/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/RcppArmadillo/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/raster/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/fields/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/ri/include" -I"C:/Users/haogechang/AppData/Local/R/win-library/4.3/geosphere/include" -I"C:/Users/HAOGEC~1/ONEDRI~1/Desktop/SPATIA~2/SPATIA~2/SPATIA~1/src" -I"C:/Users/haogechang/OneDrive - Microsoft/Desktop/SpatialReplication/SpatialReplication/SpatialEffect/inst/include" -I"C:/RBuildTools/4.3/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c effect_nonmo.cpp -o effect_nonmo.o
g++ -std=gnu++17 -shared -s -static-libgcc -o sourceCpp_4.dll tmp.def effect_nonmo.o -LC:/OpenBLAS/lib -lopenblas -LC:/RBuildTools/4.3/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/RBuildTools/4.3/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-43~1.1/bin/x64 -lR
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/haogechang/AppData/Local/Temp/RtmpmIucyH/sourceCpp-x86_64-w64-mingw32-1.0.11/sourcecpp_ad281b253d0e/sourceCpp_4.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/haogechang/OneDrive - Microsoft/Desktop/SpatialReplication/SpatialReplication/SpatialEffect/src/../inst/include": The system cannot find the path specified
I am clueless on what causes the problem…. I want to know why this happens and how I can solve it.
Thanks in advance for any help!
Haoge Chang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.