views:

78

answers:

2

Hello,

I have a problem using boost:program_options

this simple program, copy-pasted from boosts' documentation :

#include <boost/program_options.hpp>

int main( int argc, char** argv )
{

    namespace po = boost::program_options;

    po::options_description desc("Allowed options");
    desc.add_options()
        ("help", "produce help message")
        ("compression", po::value<int>(), "set compression level")
        ;
    return 0;
}

fails with a buffer overflow.

I have activated the "buffer security switch", and when I run it I get an "unknown exception (0xc0000409)" when I step over the line desc.add_options()...

I use Visual Studio 2005 and boost 1.43.0.

By the way it does run if I deactivate the switch but I don't feel comfortable doing so... unless it's possible to deactivate it locally.

So do you have a solution to this problem?

EDIT I found the problem I was linking against libboost_program_options-vc80-mt.lib which wasn't the good library.

+1  A: 

It works in 2010. Was about to try in 2005 but realized I don't have 1.43 compiled in that environment.

Noah Roberts
A: 

I found the problem I was linking against libboost_program_options-vc80-mt.lib which wasn't the good library since I changed the runtime library to Multithread DLL.

f4