optim icon indicating copy to clipboard operation
optim copied to clipboard

Error when compiling with RCpp: no match for call to function

Open ahoundetoungan opened this issue 2 years ago • 4 comments

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.

ahoundetoungan avatar Feb 06 '23 21:02 ahoundetoungan

Can you provide some details about the system you're compiling this on?

kthohr avatar Feb 08 '23 17:02 kthohr

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.

ahoundetoungan avatar Feb 10 '23 11:02 ahoundetoungan

Can you provide a minimal reproducible example that generates this error?

kthohr avatar Feb 12 '23 17:02 kthohr

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;

oelhammouchi avatar Oct 31 '23 05:10 oelhammouchi