Errors encountered when linking OpenBLAS to Rcpp

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!

New contributor

Haoge Chang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật