Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 271129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:06:44+00:00 2026-05-12T00:06:44+00:00

I’m trying to develop a cross-platform application using C++ with boost. I typically program

  • 0

I’m trying to develop a cross-platform application using C++ with boost.

I typically program in a *nix environment, where I’ve always defined ‘main’ as follows:

int main( const int argc, const char* argv[] )
{
...
}

For this application, I’m starting in the Windows environment, using Visual Studio 2003.

When I try to use boost::program_options with this definition, I get compile errors from program_options::store:

po::options_description desc("Supported options");
desc.add_options()...;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);

Error:

main.cpp(46) : error C2665: 'boost::program_options::store' : none of the 2 overloads can convert parameter 1 from type 'boost::program_options::basic_parsed_options<charT>'
    with
    [
        charT=const char
    ]
    c:\boost_1_38_0\boost\program_options\variables_map.hpp(34): could be 'void boost::program_options::store(const boost::program_options::basic_parsed_options<charT> &,boost::program_options::variables_map &,bool)'
    with
    [
        charT=char
    ]
    c:\boost_1_38_0\boost\program_options\variables_map.hpp(43): or       'void boost::program_options::store(const boost::program_options::basic_parsed_options<wchar_t> &,boost::program_options::variables_map &)'
    while trying to match the argument list '(boost::program_options::basic_parsed_options<charT>, boost::program_options::variables_map)'
    with
    [
        charT=const char
    ]

I tried to force the wchar_t function by defining main as follows:

int main( const int argc, wchar_t* argv[]){
...
}

Then it compiles, but I get link errors:

main.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 &)"  referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::program_options::basic_parsed_options<unsigned short>::basic_parsed_options<unsigned short>(class boost::program_options::basic_parsed_options<char> const &)"  referenced in function "public: class boost::program_options::basic_parsed_options<unsigned short> __thiscall boost::program_options::basic_command_line_parser<unsigned short>::run(void)" 
main.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl boost::program_options::to_internal(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"  referenced in function "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl boost::program_options::to_internal<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > >(class std::vector<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >,class std::allocator<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > > > const &)" 

Finally, if I fall back to the default main definition setup by Visual Studio, it compiles and links:

int main( const int argc, _TCHAR* argv[]){
...
}

So, that’s good for Windows, but will this work when I try to take it to *nix? Do those systems typically define a _TCHAR type? I haven’t come across it personally.

What is the proper way to define main to work on Windows and *nix, plus work with the boost::program_options library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:06:45+00:00Added an answer on May 12, 2026 at 12:06 am

    It seems to be a constness related problem. Try:

    int main( int argc, char* argv[] )
    {
      // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 189k
  • Answers 189k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer you need to compute all expressions and push into the… May 12, 2026 at 5:42 pm
  • Editorial Team
    Editorial Team added an answer Ctrl+T to view all descendants Press it the combination a… May 12, 2026 at 5:42 pm
  • Editorial Team
    Editorial Team added an answer The compiler has no guarantee that T0 and T1 can… May 12, 2026 at 5:42 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.