-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Vladimir Prus Sent: Sunday, May 29, 2005 10:53 PM To: boost-users@lists.boost.org Subject: [Boost-users] Re: Questions about Boost.ProgramOptions
Hi Elisha,
I have a few questions about Boost.ProgramOptions pertaining to
Thanks for the reply,
The compiler is VC7.1 and I rely on the compiler to automatically find
the correct library. If that is incorrect, which version should I link
to? The suffixes are a bit opaque with all of the s, g and m
characters. But before that I made changes as per the example of
unicode_test.cpp and it still doesn't compile.
Here's my code:
wstring strXmlFile;
wstring strXsdFile;
// process program options
options_description desc("allowed options");
desc.add_options()
// First parameter describes option name/short name
// The second is parameter to option
// The third is description
("help,h", "print usage message")
("validate,v", "validate xml file")
("xml", wvalue<wstring>(&strXmlFile), "xml file")
("xsd", wvalue<wstring>(&strXsdFile), "xsd file");
variables_map vm;
store(wcommand_line_parser(argc, argv).options(desc).run(), vm);
Here's the errors:
c:\Libraries\Boost\boost_1_32_0\boost\lexical_cast.hpp(144) : error
C2679: binary '<<' : no operator found which takes a right-hand operand
of type 'const std::basic_string<_Elem,_Traits,_Ax>' (or there is no
acceptable conversion)
with
[
_Elem=wchar_t,
_Traits=std::char_traits
an argv that is of wchar_t data type. The first thing that isn't clear from the examples is whether it's possible at all. The second thing that isn't clear is how to do it and store string values in std::wstring variables.
Here are the specifics:
1) How do you use program_options with an argv argument that is a wchar_t data type?
Like this?
variables_map vm; store(parse_command_line
(argc, argv, desc), vm); Exactly. You don't even need to specify 'wchar_t' explicitly.
but then the question is how do you store any of the command line values in wstring variables?
Like this?
options_description desc("allowed options"); desc.add_options() // First parameter describes option name/short name // The second is parameter to option // The third is description ("help,h", "print usage message") ("validate,v", value(&strFile), "validate xml file");
That's the supposed way. Here's a complete example taken from "test/unicode_test.cpp"
options_description desc;
desc.add_options() ("foo", po::wvalue<wstring>(), "unicode option") ;
vector<wstring> args; args.push_back(L"--foo=\x044F");
variables_map vm; store(wcommand_line_parser(args).options(desc).run(), vm);
BOOST_CHECK(vm["foo"].as<wstring>() == L"\x044F");
// strFile is a wstring
Well that doesn't work.
In what way and on what compiler and with what error messages, etc. I can't help unless you tell exactly what's wrong.
2) I am getting 3 link errors when trying the above:
ToolsTest.obj : error LNK2019: unresolved external symbol "void __cdecl boost::program_options::store(class boost::program_options::basic_parsed_options<unsigned short> const &,class boost::program_options::variables_map &)"
(?store@program_options@boost@@YAXABV?$basic_parsed_options@G@12@AAVvari
ables_map@12@@Z) referenced in function _main
Did you link to the program_options library, to begin with?
- Volodya
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users