我使用 ubuntu 10.04 和 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
这是 main.cpp(仅用于测试)
#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
我做
find /usr/include/ -name "*description*"
/usr/include/boost/program_options/options_description.hpp
而且只有一个原型。有任何想法吗?