I use ubuntu 10.04 and libboost1.40.
ls -l /usr/lib | grep boost_pro
-rw-r--r-- 1 root root 640800 2010-04-01 05:19 libboost_program_options.a
lrwxrwxrwx 1 root root 26 2011-11-03 22:40 libboost_program_options-mt.a -> libboost_program_options.a
lrwxrwxrwx 1 root root 34 2011-11-03 22:40 libboost_program_options-mt.so -> libboost_program_options.so.1.40.0
lrwxrwxrwx 1 root root 34 2011-11-03 22:40 libboost_program_options.so -> libboost_program_options.so.1.40.0
-rw-r--r-- 1 root root 289336 2010-04-01 05:19 libboost_program_options.so.1.40.0
this is main.cpp(just for testing)
#include <string>
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/options_description.hpp>
//---------------------------------------------------------------------
int main(int argc,char** argv)
{
boost::gregorian::date now(boost::gregorian::day_clock::local_day());
//is works fine
std::cout<<boost::gregorian::to_iso_string(now)<<std::endl;
boost::program_options::options_description a; //but here i get an error when the constructor have started
return 0;
}
g++ -o main -lboost_date_time -lboost_program_options main.cpp && ./main
/tmp/cc3RJHsG.o: In function `main':
main.cpp:(.text+0x81): undefined reference to `boost::program_options::options_description::options_description(unsigned int, unsigned int)'
collect2: ld returned 1 exit status
i do
find /usr/include/ -name "*description*"
/usr/include/boost/program_options/options_description.hpp
and there's only a prototype ofcouse. Any ideas?
Apparently, there is a prototype for a two-arg constructor that takes two unsigned ints, both with a default value. Hence, this becomes the default constructor, that is used when a is created. It's this constructor:
options_description(unsigned = m_default_line_length,
unsigned = m_default_line_length/2);
However, this was added in Boost 1.42 and does not exist in your version, 1.40.
So I think you somehow managed to overwrite the headers that Ubuntu installed for you, with a more recent version, but did not update the libraries in /usr/lib. Try uninstalling and reinstalling the package.
If you need a newer Boost than 1.40, either upgrade your Ubuntu, or uninstall all Boost-related packages and reinstall from source in /usr/local. The package manager will stay away from anything in /usr/local, so this will ensure that this kind of trouble does not happen again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With