boost :: filesystem :: last_write_time在哪里?

时间:2010-12-03 06:51:47

标签: c++ boost

这是我得到的链接器错误。我的boost :: filesystem的其余部分都在解决。我不明白为什么这个没有。我认为这是升力1.40的问题,所以我升级到1.44并且问题仍然存在。我正在使用#define BOOST_FILESYSTEM_VERSION 3但我没有提到在这种情况下没有提供last_write_time。即使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)

哦,是的,使用Windows VS2008。

涉及的代码是:

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

其他人遇到这个?

它也发生在#define BOOST_FILESYSTEM_VERSION 2。我正在使用的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)

来自/ 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:

2 个答案:

答案 0 :(得分:4)

好的,问题就像它是钝的一样简单。在VS2008及以上版本中,time_t为64位,除非#define _USE_32_BIT_TIME_T。在没有此定义的情况下编译boost库,因此time_t为64位。由于一些遗留问题,我的项目确实定义了_USE_32_BIT_TIME_T,因此生成了32位时间的API。

如果您构建的项目不使用32位时间,则按预期工作。

我很高兴C ++人员足够聪明,可以通过名称修改将调用签名推送到链接器中。如果他们没有这样做,我仍然想知道发生了什么。

答案 1 :(得分:0)

我想知道这个函数是否与函数参数一样存在问题。通过boost :: filesystem api,我找不到一个带有Path和time参数的last_write_detail函数,只有一个Path参数。另一方面,我找到了

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

而不是

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

所以可能错误是因为链接器找不到具有正确签名的函数版本,你应该使用last_write_time_api吗?