Boost::Date_time库和time_from_string()函数的使用
2012-10-14 21:22
441 查看
前一段时间,想在Qt中使用Stlport和Boost,结果发现了一个有些奇怪的现象,使用Boost::Data_Time库时会有链接错误,但是用其他的库就没有问题,比如foreach,fromat,string_algo。用qmake生成VC项目后和之前使用Boost::Date_Time的VC项目比较,发现差别在“将wchar_t视为内置类型”,当时用的Qt SDK是直接下载的编译好的,不支持wchar_t,为此特意下载了Qt的源码,自己修改配置然后编译,现问题已解决。在Boost中文文档上看到这段话,也证明问题确实是处在是否支持
不过我在用Stlport编译Boost时Date_Time并没有出问题,现在的Stlport应该是默认支持wchar_t。
在Boost::Date_Time的使用过程中还发现了一个问题,就是在用到time_from_string()时会报链接错误,如下:
在网上找解决办法时,都是说不能只包含头文件,还要链接相应的库,实际上不是没有链接库产生的问题。
在%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放在项目目录下即可。
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::map<class stlpd_std::basic_string<char,class stlpd_std::char_traits<char>,class stlpd_std::allocator<char> >,unsigned short,struct stlpd_std::less<class stlpd_std::basic_string<char,class stlpd_std::char_traits<char>,class stlpd_std::allocator<char> > >,class stlpd_std::allocator<struct stlpd_std::pair<class stlpd_std::basic_string<char,class stlpd_std::char_traits<char>,class stlpd_std::allocator<char> > 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 boost::gregorian::greg_month>(class stlpd_std::basic_string<char,class stlpd_std::char_traits<char>,class stlpd_std::allocator<char> > 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放在项目目录下即可。
相关文章推荐
- BOOST 使用from_simple_string与to_simple_string这类函数时连接错误
- boost date_time 下 date的使用
- mysql 时间戳格式化函数from_unixtime使用说明
- mysql格式化时间函数:FROM_UNIXTIME() DATE_FORMAT()
- mysql 时间戳格式化函数from_unixtime使用说明
- 《Boost程序完全开发》跟踪学习训练一:Boost::date_time库的使用
- mysql 时间戳格式化函数from_unixtime使用说明
- SQL Server ->> 时间函数: EOMONTH, DATEFROMPARTS, TIMEFROMPARTS, DATETIMEFROMPARTS, DATETIMEOFFSETFROMPARTS
- Mysql日期时间类型(DATE,DATETIME,TIMESTAMP)和函数及与linux系统时间之间的转换(UNIX_TIMESTAMP、FROM_UNIXTIME)
- MYSQL DATE_FORMAT以及UNIX_TIMESTAMP 和FROM_UNIXTIME 函数整理
- time value from 1970 to date string.
- Spring Mvc使用Jackson进行json转对象时,遇到的字符串转日期的异常处理(Can not deserialize value of type Date from String)
- 'Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- BOOST:使用local_date_time 计算当前时间戳
- Jmeter使用_StringFromFile函数需要添加编码方式
- boost date_time使用
- mysql时间格式函数:from_unixtime()、unix_timestamp()、date_format()
- Parse Date-time From String With PHP & MySQL
- dateFromString 函数造成时间差问题
- Boost.Date_Time 使用