[program_options] VM object unable to store the values of options
(Apologies if this message has come out for more than once, as I had
problem with authorization and is unsure when the message is able to be
seen by boost users!)
Hi,
I'm met a very weird thing when using the “Boost.Program_options”
library. Somehow, the variable-map(VM) object is unable to store values
of options which are fed in from the command line. I've been stuck in
this stupid problem for two days and cannot find any clue about it. Can
someone please give me a hint?
I'm using the Visual Studio 2005 on Windows XP SP3 to compile some
examples provided in Boost.Program_options Tutorial. The boost library
was installed using the boost_1_34_1 installer. However, no matter what
value I input to any option, the variable-map object "vm" I defined is
unable to store it and output it correctly.
For instance, I followed the instructions in the Tutorial of the
Boost.Program_options and compiled the first simplest possible example
"example/first.cpp". I then went to "start" of Windows XP and Run "cmd",
then run: "first --compression 10". The output is always "Compression
level was set to -858993460." regardless of what value I type after the
"--compression". Below is the full codes of the program (copied from the
"example/first.cpp"):
-------------------------------------------------------------------------------
#include
Wenjing Jia wrote:
For instance, I followed the instructions in the Tutorial of the Boost.Program_options and compiled the first simplest possible example "example/first.cpp". I then went to "start" of Windows XP and Run "cmd", then run: "first --compression 10". The output is always "Compression level was set to -858993460." regardless of what value I type after the "--compression". Below is the full codes of the program (copied from the "example/first.cpp"):
...
I also tried on the other examples mentioned on that web page, such as "example/options_description.cpp". When I type: "options_description --optimization 4 -I foo a.cpp", the output is: "Include paths are: Input files are: Optimization level is -858993460". That is the input values are not taken and stored by the vm object.
Why such a simple example won't work on my machine!?
I imagine that the only reason for such behaviour could be some mismatch in compilation options between the library and the program. Does the problem persist if you try a later release? Do you have RTTI enabled in your project? Do you have any options affecting ABI set to values different from default (e.g. alignment) Also, are you sure you don't have *two* boost installations, of different version, and use headers from one installation and libraries from another? - Volodya
Thanks very much for Volodya's advice! I've reinstalled a 1.37 boost and all the problems have disappeared immediately! Thanks! Wenjing Vladimir Prus wrote:
Wenjing Jia wrote:
I also tried on the other examples mentioned on that web page, such as "example/options_description.cpp". When I type: "options_description --optimization 4 -I foo a.cpp", the output is: "Include paths are: Input files are: Optimization level is -858993460". That is the input values are not taken and stored by the vm object.
Why such a simple example won't work on my machine!?
I imagine that the only reason for such behaviour could be some mismatch in compilation options between the library and the program. Does the problem persist if you try a later release? Do you have RTTI enabled in your project? Do you have any options affecting ABI set to values different from default (e.g. alignment)
Also, are you sure you don't have *two* boost installations, of different version, and use headers from one installation and libraries from another?
- Volodya
participants (2)
-
Vladimir Prus
-
Wenjing Jia