<div dir="ltr">Hi all,<br><br>I have been trying to make an R function to call my C++ simulation program in this way:<br>```c++<br>// [[Rcpp::plugins(cpp14)]]<br>#include <Rcpp.h><br>#include <mylib.hpp><br>// [[Rcpp::export]]<br>std::string run_simulation(Rcpp::CharacterVector args=Rcpp::CharacterVector::create()) {<br>    auto vs_args = Rcpp::as<std::vector<std::string>>(args);<br>    mylib::Simulation sim(vs_args);<br>    sim.run();<br>    return sim.results();<br>}<br>```<br><br>The class `Simulation` parses arguments with `boost::program_options` and is implemented in `libmylib.dylib`, which can be linked with `PKG_LIBS = -lmylib`. Both `devtools::check()` and independent `Rcpp::sourceCpp()` can successfully build the function `run_simulation()`. It runs perfectly as I intended **only if it is the first call**. The second time I call `run_simulation('-v')`, I get the following error:<br>```<br>Error: option '-v' is ambiguous and matches different versions of '--verbose'<br>```<br><br>Other options like `-h` or `--mutation=0` raise the same error. It indicates that every option is re-defined after the first call (maybe?). Calling without any argument is always OK, and an executable `a.out` built with `main.cpp -lmylib` has no problem. I guess the key is how C++ objects are cached in R environments. Is this a bug in Rcpp? Or am I missing something?<br><br>Thanks,<br><br>--<br>Watal M. Iwasaki / 岩嵜 航<br>SOKENDAI, Graduate University for Advanced Studies,<br>Hayama, Kanagawa 240-0193, Japan<br>+81-46-858-1576<br><a href="https://heavywatal.github.io/">https://heavywatal.github.io/</a>
</div>