H
Hardy
Hi, just come into the boost world. just the first.cpp in the
program_options examples, with many link error...
devc++4.9.9.2, gcc 3.4.2,
can I get your opinions on this problem? thank you~
make.exe -f "D:\temp\Makefile.win" all
g++.exe -c main.cpp
-o
ain.o -I"F:/Source/Boost/boost_1_32_0" -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"
-I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"
-I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
g++.exe main.o -o "PO.exe" -L"C:/Dev-Cpp/lib"
main.o(.text+0x1bb):main.cpp: undefined reference to
`boost:rogram_options:ptions_description:ptions_description(std::string
const&)'
main.o(.text+0x28c):main.cpp: undefined reference to
`boost:rogram_options:ptions_description::add_options()'
main.o(.text+0x2b0):main.cpp: undefined reference to
`boost:rogram_options:ptions_description_easy_init:perator()(char
const*, char const*)'
main.o(.text+0x2d2):main.cpp: undefined reference to
`boost:rogram_options:ptions_description_easy_init:perator()(char
const*, boost:rogram_options::value_semantic const*, char const*)'
main.o(.text+0x2e0):main.cpp: undefined reference to
`boost:rogram_options::variables_map::variables_map()'
main.o(.text+0x370):main.cpp: undefined reference to
`boost:rogram_options::store(boost:rogram_options::basic_parsed_options<char>
const&, boost:rogram_options::variables_map&, bool)'
main.o(.text+0x449):main.cpp: undefined reference to
`boost:rogram_options::notify(boost:rogram_options::variables_map&)'
main.o(.text+0x589):main.cpp: undefined reference to
`boost:rogram_options:perator<<(std:stream&,
boost:rogram_options:ptions_description const&)'
main.o(.text$_ZNK5boost15program_options13variables_mapixERKSs[boost:rogram_options::variables_map:perator[](std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)
const]+0x14):main.cpp: undefined reference to
`boost:rogram_options::abstract_variables_map:perator[](std::string
const&) const'
main.o(.text$_ZN5boost15program_options13variables_mapD1Ev[boost:rogram_options::variables_map::~variables_map()]+0x3a):main.cpp:
undefined reference to `vtable for boost:rogram_options::variables_map'
main.o(.text$_ZN5boost15program_options25basic_command_line_parserIcEC1EiPPc[boost:rogram_options::basic_command_line_parser<char>::basic_command_line_parser(int,
char**)]+0x9b):main.cpp: undefined reference to
`boost:rogram_options::common_command_line_parser::common_command_line_parser(std::vector<std::string,
std::allocator<std::string> > const&)'
main.o(.text$_ZNK5boost15program_options25basic_command_line_parserIcE3runEv[boost:rogram_options::basic_command_line_parser<char>::run()
const]+0x15):main.cpp: undefined reference to
`boost:rogram_options::common_command_line_parser::run() const'
main.o(.text$_ZN5boost15program_options29value_semantic_codecvt_helperIcED2Ev[boost:rogram_options::value_semantic_codecvt_helper<char>::~value_semantic_codecvt_helper()]+0xb):main.cpp:
undefined reference to `vtable for
boost:rogram_options::value_semantic_codecvt_helper<char>'
main.o(.text$_ZN5boost15program_options29value_semantic_codecvt_helperIcEC2Ev[boost:rogram_options::value_semantic_codecvt_helper<char>::value_semantic_codecvt_helper()]+0x16):main.cpp:
undefined reference to `vtable for
boost:rogram_options::value_semantic_codecvt_helper<char>'
main.o(.text$_ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_SaIS5_EE[std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >
boost:rogram_options::to_internal<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > const&)]+0xd4):main.cpp:
undefined reference to `boost:rogram_options::to_internal(std::string
const&)'
main.o(.rdata$_ZTVN5boost15program_options11typed_valueIicEE[vtable for
boost:rogram_options::typed_value<int, char>]+0x1c):main.cpp: undefined
reference to
`boost:rogram_options::value_semantic_codecvt_helper<char>:arse(boost::any&,
std::vector<std::string, std::allocator<std::string> > const&, bool) const'
main.o(.text$_ZNK5boost15program_options11typed_valueIicE4nameEv[boost:rogram_options::typed_value<int,
char>::name() const]+0x80):main.cpp: undefined reference to
`boost:rogram_options::arg'
main.o(.text$_ZNK5boost15program_options11typed_valueIicE4nameEv[boost:rogram_options::typed_value<int,
char>::name() const]+0x162):main.cpp: undefined reference to
`boost:rogram_options::arg'
main.o(.text$_ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorISbIT0_St11char_traitsIS5_ESaIS5_EESaIS9_EEPT_l[void
boost:rogram_options::validate<int, char>(boost::any&,
std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > const&, int*,
long)]+0x4c):main.cpp: undefined reference to
`boost:rogram_options::validators::check_first_occurrence(boost::any
const&)'
main.o(.text$_ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorISbIT0_St11char_traitsIS5_ESaIS5_EESaIS9_EEPT_l[void
boost:rogram_options::validate<int, char>(boost::any&,
std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > const&, int*,
long)]+0x1e1):main.cpp: undefined reference to
`boost:rogram_options::invalid_option_value::invalid_option_value(std::string
const&)'
main.o(.text$_ZN5boost15program_options16validation_errorD2Ev[boost:rogram_options::validation_error::~validation_error()]+0x3a):main.cpp:
undefined reference to `vtable for boost:rogram_options::validation_error'
main.o(.text$_ZN5boost15program_options16validation_errorD1Ev[boost:rogram_options::validation_error::~validation_error()]+0x3a):main.cpp:
undefined reference to `vtable for boost:rogram_options::validation_error'
main.o(.text$_ZN5boost15program_options16validation_errorC1ERKSs[boost:rogram_options::validation_error::validation_error(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)]+0x53):main.cpp:
undefined reference to `vtable for boost:rogram_options::validation_error'
main.o(.rdata$_ZTVN5boost15program_options20invalid_option_valueE[vtable for
boost:rogram_options::invalid_option_value]+0x10):main.cpp: undefined
reference to `boost:rogram_options::validation_error::what() const'
collect2: ld returned 1 exit status
make.exe: *** [PO.exe] Error 1
source file:
// Copyright Vladimir Prus 2002-2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
/* The simplest usage of the library.
*/
#include <boost/program_options.hpp>
namespace po = boost:rogram_options;
#include <iostream>
#include <iterator>
using namespace std;
int main(int ac, char* av[])
{
try {
po:ptions_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po:arse_command_line(ac, av, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
if (vm.count("compression")) {
cout << "Compression level was set to "
<< vm["compression"].as<int>() << ".\n";
} else {
cout << "Compression level was not set.\n";
}
}
catch(exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}
return 0;
}
program_options examples, with many link error...
devc++4.9.9.2, gcc 3.4.2,
can I get your opinions on this problem? thank you~
make.exe -f "D:\temp\Makefile.win" all
g++.exe -c main.cpp
-o
ain.o -I"F:/Source/Boost/boost_1_32_0" -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"
-I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"
-I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
g++.exe main.o -o "PO.exe" -L"C:/Dev-Cpp/lib"
main.o(.text+0x1bb):main.cpp: undefined reference to
`boost:rogram_options:ptions_description:ptions_description(std::string
const&)'
main.o(.text+0x28c):main.cpp: undefined reference to
`boost:rogram_options:ptions_description::add_options()'
main.o(.text+0x2b0):main.cpp: undefined reference to
`boost:rogram_options:ptions_description_easy_init:perator()(char
const*, char const*)'
main.o(.text+0x2d2):main.cpp: undefined reference to
`boost:rogram_options:ptions_description_easy_init:perator()(char
const*, boost:rogram_options::value_semantic const*, char const*)'
main.o(.text+0x2e0):main.cpp: undefined reference to
`boost:rogram_options::variables_map::variables_map()'
main.o(.text+0x370):main.cpp: undefined reference to
`boost:rogram_options::store(boost:rogram_options::basic_parsed_options<char>
const&, boost:rogram_options::variables_map&, bool)'
main.o(.text+0x449):main.cpp: undefined reference to
`boost:rogram_options::notify(boost:rogram_options::variables_map&)'
main.o(.text+0x589):main.cpp: undefined reference to
`boost:rogram_options:perator<<(std:stream&,
boost:rogram_options:ptions_description const&)'
main.o(.text$_ZNK5boost15program_options13variables_mapixERKSs[boost:rogram_options::variables_map:perator[](std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)
const]+0x14):main.cpp: undefined reference to
`boost:rogram_options::abstract_variables_map:perator[](std::string
const&) const'
main.o(.text$_ZN5boost15program_options13variables_mapD1Ev[boost:rogram_options::variables_map::~variables_map()]+0x3a):main.cpp:
undefined reference to `vtable for boost:rogram_options::variables_map'
main.o(.text$_ZN5boost15program_options25basic_command_line_parserIcEC1EiPPc[boost:rogram_options::basic_command_line_parser<char>::basic_command_line_parser(int,
char**)]+0x9b):main.cpp: undefined reference to
`boost:rogram_options::common_command_line_parser::common_command_line_parser(std::vector<std::string,
std::allocator<std::string> > const&)'
main.o(.text$_ZNK5boost15program_options25basic_command_line_parserIcE3runEv[boost:rogram_options::basic_command_line_parser<char>::run()
const]+0x15):main.cpp: undefined reference to
`boost:rogram_options::common_command_line_parser::run() const'
main.o(.text$_ZN5boost15program_options29value_semantic_codecvt_helperIcED2Ev[boost:rogram_options::value_semantic_codecvt_helper<char>::~value_semantic_codecvt_helper()]+0xb):main.cpp:
undefined reference to `vtable for
boost:rogram_options::value_semantic_codecvt_helper<char>'
main.o(.text$_ZN5boost15program_options29value_semantic_codecvt_helperIcEC2Ev[boost:rogram_options::value_semantic_codecvt_helper<char>::value_semantic_codecvt_helper()]+0x16):main.cpp:
undefined reference to `vtable for
boost:rogram_options::value_semantic_codecvt_helper<char>'
main.o(.text$_ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_SaIS5_EE[std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >
boost:rogram_options::to_internal<std::basic_string<char,
std::allocator<char> >, std::allocator<std::basic_string<char,(std::vector<std::basic_string<char, std::char_traits<char>,
std::char_traits<char>, std::allocator<char> > > > const&)]+0xd4):main.cpp:
undefined reference to `boost:rogram_options::to_internal(std::string
const&)'
main.o(.rdata$_ZTVN5boost15program_options11typed_valueIicEE[vtable for
boost:rogram_options::typed_value<int, char>]+0x1c):main.cpp: undefined
reference to
`boost:rogram_options::value_semantic_codecvt_helper<char>:arse(boost::any&,
std::vector<std::string, std::allocator<std::string> > const&, bool) const'
main.o(.text$_ZNK5boost15program_options11typed_valueIicE4nameEv[boost:rogram_options::typed_value<int,
char>::name() const]+0x80):main.cpp: undefined reference to
`boost:rogram_options::arg'
main.o(.text$_ZNK5boost15program_options11typed_valueIicE4nameEv[boost:rogram_options::typed_value<int,
char>::name() const]+0x162):main.cpp: undefined reference to
`boost:rogram_options::arg'
main.o(.text$_ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorISbIT0_St11char_traitsIS5_ESaIS5_EESaIS9_EEPT_l[void
boost:rogram_options::validate<int, char>(boost::any&,
std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > const&, int*,
long)]+0x4c):main.cpp: undefined reference to
`boost:rogram_options::validators::check_first_occurrence(boost::any
const&)'
main.o(.text$_ZN5boost15program_options8validateIicEEvRNS_3anyERKSt6vectorISbIT0_St11char_traitsIS5_ESaIS5_EESaIS9_EEPT_l[void
boost:rogram_options::validate<int, char>(boost::any&,
std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > const&, int*,
long)]+0x1e1):main.cpp: undefined reference to
`boost:rogram_options::invalid_option_value::invalid_option_value(std::string
const&)'
main.o(.text$_ZN5boost15program_options16validation_errorD2Ev[boost:rogram_options::validation_error::~validation_error()]+0x3a):main.cpp:
undefined reference to `vtable for boost:rogram_options::validation_error'
main.o(.text$_ZN5boost15program_options16validation_errorD1Ev[boost:rogram_options::validation_error::~validation_error()]+0x3a):main.cpp:
undefined reference to `vtable for boost:rogram_options::validation_error'
main.o(.text$_ZN5boost15program_options16validation_errorC1ERKSs[boost:rogram_options::validation_error::validation_error(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)]+0x53):main.cpp:
undefined reference to `vtable for boost:rogram_options::validation_error'
main.o(.rdata$_ZTVN5boost15program_options20invalid_option_valueE[vtable for
boost:rogram_options::invalid_option_value]+0x10):main.cpp: undefined
reference to `boost:rogram_options::validation_error::what() const'
collect2: ld returned 1 exit status
make.exe: *** [PO.exe] Error 1
source file:
// Copyright Vladimir Prus 2002-2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
/* The simplest usage of the library.
*/
#include <boost/program_options.hpp>
namespace po = boost:rogram_options;
#include <iostream>
#include <iterator>
using namespace std;
int main(int ac, char* av[])
{
try {
po:ptions_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po:arse_command_line(ac, av, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
if (vm.count("compression")) {
cout << "Compression level was set to "
<< vm["compression"].as<int>() << ".\n";
} else {
cout << "Compression level was not set.\n";
}
}
catch(exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}
return 0;
}