I am on Ubuntu 14.04, using CMake and CLion. I am trying to use Program Options, with the following code taken from an example in their documentation:
#include <iostream>
#include <boost/program_options.hpp>
int main(int ac, char* av[]) {
namespace po = boost::program_options;
using namespace std;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
if (vm.count("compression")) {
cout << "Compression level was set to "
<< vm["compression"].as<int>() << ".\n";
} else {
cout << "Compression level was not set.\n";
}
}
When I run it, I get the following output from the terminal:
$ ./bin/webserver --help
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::logic_error> >'
what(): character conversion failed
Aborted (core dumped)
Why is that not working and how can I solve it?
EDIT: After some debugging, I found that the problem comes from the line with store
, if this is of any help for you. Also, I have to mention I tried using store(..., true)
(setting unicode
to true
)