博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Boost::Date_time库和time_from_string()函数的使用
阅读量:6909 次
发布时间:2019-06-27

本文共 1849 字,大约阅读时间需要 6 分钟。

  前一段时间,想在Qt中使用Stlport和Boost,结果发现了一个有些奇怪的现象,使用Boost::Data_Time库时会有链接错误,但是用其他的库就没有问题,比如foreach,fromat,string_algo。用qmake生成VC项目后和之前使用Boost::Date_Time的VC项目比较,发现差别在“将wchar_t视为内置类型”,当时用的Qt SDK是直接下载的编译好的,不支持wchar_t,为此特意下载了Qt的源码,自己修改配置然后编译,现问题已解决。在Boost中文文档上看到这段话,也证明问题确实是处在是否支持 wchar_t。截图如下:

不过我在用Stlport编译Boost时Date_Time并没有出问题,现在的Stlport应该是默认支持wchar_t。

  在Boost::Date_Time的使用过程中还发现了一个问题,就是在用到time_from_string()时会报链接错误,如下:

错误    1    error LNK2019: 无法解析的外部符号 "public: static class boost::shared_ptr
,class stlpd_std::allocator
>,unsigned short,struct stlpd_std::less
,class stlpd_std::allocator
> >,class stlpd_std::allocator
,class stlpd_std::allocator
> const ,unsigned short> > > > __cdecl boost::gregorian::greg_month::get_month_map_ptr(void)" (?get_month_map_ptr@greg_month@gregorian@boost@@SA?AV?$shared_ptr@V?$map@V?$basic_string@DV?$char_traits@D@stlpd_std@@V?$allocator@D@2@@stlpd_std@@GU?$less@V?$basic_string@DV?$char_traits@D@stlpd_std@@V?$allocator@D@2@@stlpd_std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DV?$char_traits@D@stlpd_std@@V?$allocator@D@2@@stlpd_std@@G@stlpd_std@@@2@@stlpd_std@@@3@XZ),该符号在函数 "unsigned short __cdecl boost::date_time::month_str_to_ushort
(class stlpd_std::basic_string
,class stlpd_std::allocator
> const &)" (??$month_str_to_ushort@Vgreg_month@gregorian@boost@@@date_time@boost@@YAGABV?$basic_string@DV?$char_traits@D@stlpd_std@@V?$allocator@D@2@@stlpd_std@@@Z) 中被引用

在网上找解决办法时,都是说不能只包含头文件,还要链接相应的库,实际上不是没有链接库产生的问题。

  在%BOOST%/lib/date_time/src/gregorian目录下,有greg_month.cpp和greg_names.hpp两个文件,前面无法解析的get_month_map_ptr(void)就定义在greg_month.cpp中,而greg_month.cpp又依赖greg_names.hpp,只需将greg_month.cpp加入项目,greg_names.hpp放在项目目录下即可。

 

转载于:https://www.cnblogs.com/mian/archive/2012/10/14/2723394.html

你可能感兴趣的文章
selenium测试(Java)-- 显式等待(九)
查看>>
MySQL 5.7 mysqlpump 备份工具说明
查看>>
Entity Framework Core 之数据库迁移
查看>>
ssh的用户配置文件config管理ssh会话
查看>>
安全过滤函数
查看>>
C#学习记录二:高级数据存储方式
查看>>
【162】一个程序只能运行一个
查看>>
8小时与8节课
查看>>
字符串阵列分别输出元素的索引,原值和长度
查看>>
重复输出字符或字符串
查看>>
我的AI之路 —— OCR文字识别快速体验版
查看>>
Android开发指南(43) —— Location and Maps
查看>>
浏览器的两种模式quirks mode 和strict mode
查看>>
矩形运算
查看>>
解剖SQLSERVER 第二篇 对数据页面头进行逆向(译)
查看>>
处理dataTable的行和列数据
查看>>
JavaEE填空与判断
查看>>
成果展示-RSA算法工具
查看>>
Sitecore标准模板字段
查看>>
poj 1088 滑雪
查看>>