|
Boost Users : |
From: Elisha Berns (e.berns_at_[hidden])
Date: 2005-05-31 01:17:40
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<wchar_t>,
_Ax=std::allocator<wchar_t>
]
c:\Libraries\Boost\boost_1_32_0\boost\lexical_cast.hpp(143) :
while compiling class-template member function 'bool
boost::detail::lexical_stream<Target,Source>::operator <<(const Source
&)'
with
[
Target=std::wstring,
Source=std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocato
r<wchar_t>>
]
c:\Libraries\Boost\boost_1_32_0\boost\lexical_cast.hpp(186) :
see reference to class template instantiation
'boost::detail::lexical_stream<Target,Source>' being compiled
with
[
Target=std::wstring,
Source=std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocato
r<wchar_t>>
]
c:\Libraries\Boost\boost_1_32_0\boost\program_options\detail\value_seman
tic.hpp(81) : see reference to function template instantiation 'Target
boost::lexical_cast<T,std::basic_string<_Elem,_Traits,_Ax>>(Source)'
being compiled
with
[
Target=std::wstring,
T=std::wstring,
_Elem=wchar_t,
_Traits=std::char_traits<wchar_t>,
_Ax=std::allocator<wchar_t>,
Source=std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocato
r<wchar_t>>
]
c:\Libraries\Boost\boost_1_32_0\boost\program_options\detail\value_seman
tic.hpp(149) : see reference to function template instantiation 'void
boost::program_options::validate<T,wchar_t>(boost::any &,const
std::vector<_Ty> &,T *,long)' being compiled
with
[
T=std::wstring,
_Ty=std::wstring
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\map(36) : while compiling class-template member
function 'void
boost::program_options::typed_value<T,charT>::xparse(boost::any &,const
std::vector<_Ty> &) const'
with
[
T=std::wstring,
charT=wchar_t,
_Ty=std::wstring
]
c:\Samples\XMLComponents\Composite\XmlTools\XmlToolsTest.cpp(46)
: see reference to class template instantiation
'boost::program_options::typed_value<T,charT>' being compiled
with
[
T=std::wstring,
charT=wchar_t
]
c:\Libraries\Boost\boost_1_32_0\boost\lexical_cast.hpp(144) : error
C2228: left of '.fail' must have class/struct/union type
Thanks for any help here,
Elisha
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Vladimir Prus
> Sent: Sunday, May 29, 2005 10:53 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Re: Questions about Boost.ProgramOptions
>
> Hi Elisha,
>
> > I have a few questions about Boost.ProgramOptions pertaining to
parsing
> > 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<wchar_t>(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_at_program_options_at_boost@@YAXABV?$basic_parsed_options_at_G@12_at_AAVvari
> > ables_map_at_12@@Z) referenced in function _main
>
> Did you link to the program_options library, to begin with?
>
> - Volodya
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net