0

I am trying to get a get the boost library program_options working on a simple windows console library. I have linked in the library C:\Program Files\boost\boost_1_40\lib\libboost_program_options-vc90-s-1_40.lib Included the header files

#include <boost/program_options.hpp>
#include <boost/program_options/config.hpp>
#include <boost/program_options/option.hpp>
#include <boost/program_options/detail/cmdline.hpp>
#include <boost/program_options/detail/parsers.hpp >

Defined _WIN32 (But I don't think it is required.)

And I still keep getting the

Error   1   error C3861: 'split_winmain': identifier not found

It should be so simple but I can't get it to work. Can anyone tell me what I need to do here. Joseph Shanahan

Frank Krueger
  • 69,552
  • 46
  • 163
  • 208
Joseph Shanahan
  • 197
  • 1
  • 1
  • 10

1 Answers1

1

That function is declared in the boost::program_options namespace. If all you do is use its name alone, the compiler doesn't know what you're talking about. You have a few options:

  • Use the fully qualified name when you call it:

    boost::program_options::split_winmain(...);
    
  • Tell the compiler which function you mean:

    using boost::program_options::split_winmain;
    split_winmain(...);
    
  • Bring the entire namespace into the current scope:

    using namespace boost::program_options;
    split_winmain(...);
    
  • Make a namespace alias:

    namespace po = boost::program_options;
    po::split_winmain(...);
    

I prefer the last one.

Do not define the _WIN32 macro; the compiler will do that for you when it's appropriate.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • There are some boost libaries which you need to build and including the header file in not sufficient program_options is one of these. You will get the information which you require at the following website. http://www.boost.org/doc/libs/1_40_0/more/getting_started/windows.html – Joseph Shanahan Nov 12 '09 at 09:35
  • I understand that. It's essentially what I told you in my response to your "follow-up answer." That's a linker issue. It's not relevant to compiler issue that this question and my answer are about. – Rob Kennedy Nov 12 '09 at 17:39