用到boost时间,编译报错

boost::gregorian::date myDate ( boost::gregorian::day_clock::local_day());

std::string today = boost::gregorian::to_iso_string(myDate);

第一句,date前要加命名空间;

第二句,报错:

/tmp/ccaSDZPD.o: In function `boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::ostream&)':
type_cast_test.cpp:(.text._ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo]+0x33): undefined reference to `boost::gregorian::greg_month::as_short_string() const'
type_cast_test.cpp:(.text._ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo]+0x56): undefined reference to `boost::gregorian::greg_month::as_long_string() const'

网上查到解决方法:

(Be careful! This library sneakily appears to work as a header-only library at optimization levels -O2and higher, due to inlining; but it will fail to link when you use lower optimization levels where the compiler's inliner isn't as aggressive.)

g++ -o edv-urlaub-xml.exe "src\\xml.o" "src\\sql.o" "src\\header\\tinyxml2\\tinyxml2.o" "src\\config.o" "src\\Main.o" -lodbc32 -lcomctl32 -lboost_date_time c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lboost_date_time Can you tell me what I'm doing wrong? Getting really frustrated.

编译加上-lboost_date_time,解决

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值