这被问了好几次,但我不知道我做错了什么。我正在尝试将当前日期减去 7。这是主要的:
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/date_formatting.hpp>
#include <boost/date_time/gregorian/greg_month.hpp>
using namespace std;
using namespace boost::gregorian;
int main(int argc, char **argv) {
time_t rawtime;
struct tm *timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
date cdate(timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday);
cdate += date_duration(-7);
string date = to_iso_string(cdate);
cout << date << endl;
return 0;
}
当我尝试编译它时,我收到以下错误。
E:/include/boost/date_time/date_formatting.hpp:44: undefined reference to `boost::gregorian::greg_month::as_short_string() const'
E:/include/boost/date_time/date_formatting.hpp:49: undefined reference to `boost::gregorian::greg_month::as_long_string() const'
任何人都可以帮忙吗?我以为我包含了必要的文件..