I have the following code example:
#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 using, for example, g++ test.cpp -lboost_program_options . However, if I try to activate the GCC bounds check by calling 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 cannot find the 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 the usual std::vector . But why is this happening? And does anyone know a workaround for Boost program settings to work with GLIBCXX_DEBUG ?
I am using the following system:
- Debian Wheezy
- g ++ (Debian 4.7.2-5) 4.7.2
- libboost-all-dev 1.49.0.1 installed with aptitude
Thanks for any help
c ++ boost linker g ++ boost-program-options
Haatschii
source share