Boost date conversion error from/to string
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include<iostream>
#include<string> #include”boost/date_time.hpp” using namespace std; using namespace boost::gregorian; int main() { string s(“2001-10-9”); date d=from_simple_string(s); cout << to_simple_string(d) << endl; return 0; } |
这段代码给出了三个错误
/usr/include/boost/date_time/date_formatting.hpp:44: undefined reference to `boost::gregorian::greg_month::as_short_string() const’
/usr/include/boost/date_time/date_formatting.hpp:49: undefined reference to `boost::gregorian::greg_month::as_long_string() const’
/usr/include/boost/date_time/date_parsing.hpp:67: undefined reference to `boost::gregorian::greg_month::get_month_map_ptrabi:cxx11′
我正在使用 netbeans,ubuntu 16.04,boost 1.58.0,g 5.4
这些错误究竟是什么意思,我该如何解决?
编译时,添加标志 -lboost_date_time 以链接到 boost 日期时间库。
Netbeans 中应该有一种正式的方式来添加库。找到它,然后添加 boost_date_time 以链接到您的可执行文件。
- 如何用 netbeans 添加你的建议???
- @AnamulHasan 我为您搜索了它:stackoverflow.com/questions/15040303/…
- 非常感谢兄弟。它终于起作用了。
来源:https://www.codenong.com/49510164/