Boost logo

Boost Users :

Subject: [Boost-users] program_options, parse_config_file problems
From: Andrew E Slaughter (andrew.e.slaughter_at_[hidden])
Date: 2012-04-25 20:48:58


Hello,

I am attempting to parse configuration options from a file using
Boost::program_options. I am following the example provided on the
website
(http://www.boost.org/doc/libs/1_49_0/doc/html/program_options/overview.html#id2501135):

variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
store(parse_config_file("example.cfg", desc), vm);
notify(vm);

I have included the following related to program_options:
#include <boost/program_options.hpp> // Boost Program Options
#include <boost/program_options/positional_options.hpp>
#include <boost/program_options/parsers.hpp>

I have the exact code as above in my program but receive the following
error. The program works fine if I comment out the line with the
parse_config_file line. Can someone please help me get this working.

Thanks,
Andrew

--- COMPILER ERROR --------------------------
/home/slaughter/Documents/programs/source/common/user_options/user_options.cpp:
In member function ‘void
SlaughterCommon::User_options::apply_options(int, char**)’:
/home/slaughter/Documents/programs/source/common/user_options/user_options.cpp:27:76:
error: no matching function for call to ‘parse_config_file(const char
[22], boost::program_options::options_description&, bool)’
/home/slaughter/Documents/programs/source/common/user_options/user_options.cpp:27:76:
note: candidates are:
/usr/include/boost/program_options/parsers.hpp:163:5: note:
template<class charT>
boost::program_options::basic_parsed_options<charT>
boost::program_options::parse_config_file(std::basic_istream<charT>&,
const boost::program_options::options_description&, bool)
/usr/include/boost/program_options/parsers.hpp:176:5: note:
template<class charT>
boost::program_options::basic_parsed_options<charT>
boost::program_options::parse_config_file(const char*, const
boost::program_options::options_description&, bool)
make[3]: ***
[source/common/CMakeFiles/common.dir/user_options/user_options.cpp.o]
Error 1
make[2]: *** [source/common/CMakeFiles/common.dir/all] Error 2
make[1]: *** [source/common/CMakeFiles/test_user_options.dir/rule] Error 2
make: *** [test_user_options] Error 2


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