optim
optim copied to clipboard
Error when compiling with RCpp: no match for call to function
I get these errors when compiling my the cpp file with Rcpp
From the file nm.hpp
unconstrained/nm.hpp:230:58: error: no match for call to ‘(optim::ColVec_t {aka arma::Col<double>}) (optim::ColVecUInt_t&)’
From the file core/access.hpp
core/access.hpp:27:43: error: no matching function for call to ‘arma::Mat<double>::rows(optim::ColVecUInt_t&)’
I also got a lot of notes and warnings: for example int used at the place of long. Did I miss something? I followed method 2 for the installation.
Can you provide some details about the system you're compiling this on?
Thank you for your answer. I tested on many computers but all have Ubuntu (20.04 somewhere and 22.04 somewhere). I thought that I should update RcppArmadillo. But that does not fix the issue.
Can you provide a minimal reproducible example that generates this error?
I've experienced this problem as well. It appears to be related to the fact that RcppArmadillo forces the use of 32 bit integers (this is required by R itself, see https://stackoverflow.com/questions/57802546/unable-to-load-armadillo-cubeuword-when-using-rcpparmadillo). I managed to solve it by replacing line 150 in include/misc/optim_options.hpp from
using ColVecUInt_t = arma::Col<unsigned long long>;
to
using ColVecUInt_t = arma::uvec;