from_string我有以下代碼:使用具有升壓日期
#include <iostream>
#include <string>
#include <iomanip>
#include <locale>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/gregorian/parsers.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>
using namespace boost::posix_time;
using namespace boost::gregorian;
int main(int argc, char *argv[])
{
std::string ds("2011-01-02");
date dt(from_string(ds));
date_facet *f=new date_facet("%Y-%m-%d");
std::locale loc=std::locale(std::locale::classic(),f);
std::cout.imbue(loc);
std::cout<<dt<<std::endl;
return 0;
}
,當我編譯它,我得到以下錯誤:
/tmp/ccBWTFcx.o: In function `unsigned short boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
b.cpp:(.text._ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtRKSs[unsigned short boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x97): undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()'
collect2: ld returned 1 exit status
這是一個庫鏈接的問題?
是的,這是一個庫的鏈接問題。你有沒有鏈接增強靜態庫? –
nope,我沒有,我只是做了,我得到了我列在下面的錯誤.... – itcplpl