Reputation: 6758
I have this file
#include <boost/program_options.hpp>
namespace po = boost::program_options;
#include <iostream>
using namespace std;
int main(int ac, char* av[])
{
try {
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
;
}
catch(exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}
return 0;
}
Now I am trying to compile like this:
g++ -I /usr/include/boost/ -I /usr/include/boost/program_options main.cpp -L /usr/lib/x86_64-linux-gnu/ -lboost_program_options
and I am receiving this
undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string, std::allocator > const&, unsigned int, unsigned int)'
I don't know why it is failing, the library is there and the header file too. What goes wrong? I am using boost 1.55.0
administrator@administrator-VirtualBox:~/l/b$ sudo updatedb
administrator@administrator-VirtualBox:~/l/b$ locate libboost_program_options
/usr/lib/x86_64-linux-gnu/libboost_program_options.a
/usr/lib/x86_64-linux-gnu/libboost_program_options.so
/usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.55.0
Upvotes: 3
Views: 4773
Reputation: 136208
Looks like boost was compiled with pre-C++11 std::basic_string
, whereas your code is compiled with C++11 std::basic_string
.
Try re-compiling your code with -D_GLIBCXX_USE_CXX11_ABI=0
compiler command line option. See GCC5 and the C++11 ABI for more details:
In most cases, it will be obvious when this flag is needed because of errors from the linker complaining about unresolved symbols involving
__cxx11
.
Upvotes: 9