Boost logo

Boost Users :

Subject: [Boost-users] Command Line Options Questions
From: Jon Lederman (jonlederman_at_[hidden])
Date: 2016-03-06 11:43:27


I have two questions re: the boost command line options library:

1) I am compiling a dynamic library that links to the boost command line options library as a shared library. When I try to unload the dynamic library, I find that it isn’t properly unloaded and the boost library seems to be causing the issue. I did find that things were helped somewhat when I linked to the boost static libraries. However, it still feels unstable. Are there any particular things I should know about in this context in terms of how my makefile should be linking to boost? Or are there other things I should look at.

2) When using program options, I am getting the following error. For some reason this seemed to work with the dynamic libraries (or it may be a coincidence). Am I required to implement the << and >> operators? It had been compiling previously and stopped. After googling this issue there seems to be a lot of confusion. Any help would be greatly appreciated.

in file included from /usr/include/boost/any.hpp:27:0,
                 from /usr/include/boost/program_options/value_semantic.hpp:12,
                 from /usr/include/boost/program_options/options_description.hpp:13,
                 from /usr/include/boost/program_options.hpp:15,
                 from /usr/local/src/freeswitch/src/mod/applications/mod_sc_dsp/mod_sc_dsp.cpp:23:
/usr/include/boost/lexical_cast.hpp: In instantiation of 'struct boost::detail::deduce_target_char_impl<boost::detail::deduce_character_type_later<dsp_type> >':
/usr/include/boost/lexical_cast.hpp:415:89: required from 'struct boost::detail::deduce_target_char<dsp_type>'
/usr/include/boost/lexical_cast.hpp:674:92: required from 'struct boost::detail::lexical_cast_stream_traits<std::basic_string<char>, dsp_type>'
/usr/include/boost/lexical_cast.hpp:2363:19: required from 'static Target boost::detail::lexical_cast_do_cast<Target, Source>::lexical_cast_impl(const Source&) [with Target = dsp_type; Source = std::basic_string<char>]'
/usr/include/boost/lexical_cast.hpp:2543:50: required from 'Target boost::lexical_cast(const Source&) [with Target = dsp_type; Source = std::basic_string<char>]'
/usr/include/boost/program_options/detail/value_semantic.hpp:89:38: required from 'void boost::program_options::validate(boost::any&, const std::vector<std::basic_string<charT> >&, T*, long int) [with T = dsp_type; charT = char]'
/usr/include/boost/program_options/detail/value_semantic.hpp:170:55: required from 'void boost::program_options::typed_value<T, charT>::xparse(boost::any&, const std::vector<std::basic_string<charT> >&) const [with T = dsp_type; charT = char]'
/usr/local/src/freeswitch/src/mod/applications/mod_sc_dsp/mod_sc_dsp.cpp:484:1: required from here
/usr/include/boost/lexical_cast.hpp:388:13: error: static assertion failed: Target type is neither std::istream`able nor std::wistream`able
             BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value),

        ("help", "Generates help message")
        ("dsp_type", po::value<dsp_type>(&params.dsp_type)->required(), “")

where dsp_type is this:

struct dsp_type {
        dsp_type() {}
        dsp_type(std::string const& val):
        { }

        std::string value;

and I have a validator defined as this:

void validate(boost::any& v,
              std::vector<std::string> const& values,
              dsp_type* /* target_type */,
  using namespace boost::program_options;
  //namespace po = boost::program_options;

  // Make sure no previous assignment to 'v' was made.

  // Extract the first string from 'values'. If there is more than
  // one string, it's an error, and exception will be thrown.
  std::string const& s = validators::get_single_string(values);

  if (s == "ladspa" || s == "audioweaver" || s == "gstreamer" || s == "lv2") {
    v = boost::any(dsp_type(s));
  } else {
    throw validation_error(validation_error::invalid_option_value);

/usr/local/src/freeswitch/build/modmake.rules:214: recipe for target 'mod_sc_dsp.lo' failed
make[1]: *** [mod_sc_dsp.lo] Error 1

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at