简体   繁体   English

boost :: filesystem :: last_write_time在哪里?

[英]Where is boost::filesystem::last_write_time?

This is the linker error I'm getting. 这是我得到的链接器错误。 All the rest of my boost::filesystem things are resolving. 我的boost :: filesystem的其余部分都在解决。 I'm not understanding why this one does not. 我不明白为什么这个没有。 I thought it was a problem with boost 1.40, so I upgraded to 1.44 and the problem remains. 我认为这是升力1.40的问题,所以我升级到1.44并且问题仍然存在。 I'm using #define BOOST_FILESYSTEM_VERSION 3 but I see no mention of last_write_time not being provided in that case. 我正在使用#define BOOST_FILESYSTEM_VERSION 3但我没有看到在这种情况下没有提供last_write_time。 It seems the underlying implementation is missing, even though the api portion is present. 即使api部分存在,似乎缺少底层实现。

1>TestPruner.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem3::detail::last_write_time(class boost::filesystem3::path const &,long,class boost::system::error_code *)" (?last_write_time@detail@filesystem3@boost@@YAXABVpath@23@JPAVerror_code@system@3@@Z) referenced in function "void __cdecl boost::filesystem3::last_write_time(class boost::filesystem3::path const &,long)" (?last_write_time@filesystem3@boost@@YAXABVpath@12@J@Z)

Oh yea, using Windows VS2008. 哦,是的,使用Windows VS2008。

The code involved is: 涉及的代码是:

time_t curTime = time(NULL);
bfs::last_write_time(bfs::path("TestData/PruneTest/completed/Batch001.DAT"), curTime);

Anyone else run into this? 其他人遇到这个?

And it happens with #define BOOST_FILESYSTEM_VERSION 2 as well. 它也发生在#define BOOST_FILESYSTEM_VERSION 2中。 The Boost libraries I'm using are from boostpro (prebuilt, yea, I'm lazy) 我正在使用的Boost库来自boostpro(预制,是的,我很懒)

2>TestPruner.obj : error LNK2019: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem2::detail::last_write_time_api(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,long)" (?last_write_time_api@detail@filesystem2@boost@@YA?AVerror_code@system@3@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@J@Z) referenced in function "void __cdecl boost::filesystem2::last_write_time<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >(class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> const &,long)" (??$last_write_time@V?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@filesystem2@boost@@@filesystem2@boost@@YAXABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@01@J@Z)

From /versbose:lib 来自/ versbose:lib

Searching e:\Program Files\boost\boost_1_44\lib\libboost_thread-vc90-mt-gd-1_44.lib:
Searching e:\Program Files\boost\boost_1_44\lib\libboost_date_time-vc90-mt-gd-1_44.lib:

Ok, the problem is as simple as it is obtuse. 好吧,问题就像它是钝的一样简单。 In VS2008 and above time_t is 64 bits, unless you #define _USE_32_BIT_TIME_T . 在VS2008及以上时间time_t是64位,除非你#define _USE_32_BIT_TIME_T The boost libraries are compiled without this definition and therefore time_t is 64 bits for them. 在没有此定义的情况下编译boost库,因此time_t为64位。 My project due to some legacy issues does define _USE_32_BIT_TIME_T and therefore generates the API with a 32 bit time. 由于一些遗留问题,我的项目确实定义了_USE_32_BIT_TIME_T,因此生成了32位时间的API。

If you build a project that doesn't use 32 bit time, it works as expected. 如果您构建一个不使用32位时间的项目,它将按预期工作。

I'm glad the C++ guys were smart enough to push the call signature into the linker with name mangling. 我很高兴C ++人员足够聪明,可以通过名称修改将调用签名推送到链接器中。 If they hadn't done that, I'd still be wondering what was going on. 如果他们没有这样做,我仍然想知道发生了什么。

I wonder if this is so much a problem with the function as with the function arguments. 我想知道这个函数是否与函数参数一样存在问题。 Looking through the boost::filesystem api, I couldn't find a last_write_detail function with both Path and time arguments, only a Path argument. 通过boost :: filesystem api,我找不到一个带有Path和time参数的last_write_detail函数,只有一个Path参数。 On the other hand I did find 另一方面,我确实找到了

last_write_time_api( const std::string & ph, std::time_t new_value );

as opposed to 而不是

BOOST_FS_FUNC(std::time_t) last_write_time( const Path & ph )

So maybe the error is because the linker can't find a version of the function with the right signature, and you should be using last_write_time_api instead? 所以可能错误是因为链接器找不到具有正确签名的函数版本,您应该使用last_write_time_api吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM