I have the following sample code:
#include <iostream>
#include <boost/program_options.hpp>
int main ( int ac, char *av[] ) {
// Declare the supported options.
boost::program_options::options_description desc("Allowed options");
desc.add_options()("help", "produce help message");
boost::program_options::variables_map vm;
boost::program_options::store(boost::program_options::parse_command_line(ac, av, desc), vm);
return 0;
}
It compiles fine using e.g. g++ test.cpp -lboost_program_options
.
However if I try to activate GCC bounds checking with the call g++ test.cpp -lboost_program_options -D_GLIBCXX_DEBUG
, it throws the following linker error:
/tmp/ccZLdZ1g.o: In function `boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)':
test.cpp:(.text._ZN5boost15program_options25basic_command_line_parserIcEC2EiPKPKc[_ZN5boost15program_options25basic_command_line_parserIcEC5EiPKPKc]+0x97): undefined reference to `boost::program_options::detail::cmdline::cmdline(std::__debug::vector<std::string, std::allocator<std::string> > const&)'
collect2: error: ld returned 1 exit status
As far as I understand the linker can't find the function boost::program_options::detail::cmdline::cmdline(std::__debug::vector<std::string, std::allocator<std::string> > const&)
, because its argument is replaced by a debug vector instead of normal std::vector
. But why does this happen? And does anyone know a workaround, to make Boost Program Options work with GLIBCXX_DEBUG
?
I use the following system:
- Debian Wheezy
- g++ (Debian 4.7.2-5) 4.7.2
- libboost-all-dev 1.49.0.1, installed via aptitude
Thanks for any help
boost::program_options
– DikeGLIBCXX_DEBUG
, right? So is there a convenient way to get those and to switch between the two? – Ecchymosis-dev
suffix generally means the package includes developer headers and libraries to link against. It does not imply libstdc++ iterator debugging is enabled. – Beasley