这是我收到的链接器错误。我的所有其他 boost::filesystem 事情都在解决。我不明白为什么这个不。以为是boost 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:
最佳答案
好的,问题很简单,也很钝。在 VS2008 及更高版本中,time_t 是 64 位,除非你#define _USE_32_BIT_TIME_T
。 boost 库是在没有这个定义的情况下编译的,因此 time_t 对它们来说是 64 位的。由于一些遗留问题,我的项目确实定义了 _USE_32_BIT_TIME_T,因此生成了具有 32 位时间的 API。
如果您构建的项目不使用 32 位时间,它会按预期工作。
我很高兴 C++ 人员足够聪明,可以将调用签名推送到带有名称修改的链接器中。如果他们没有那样做,我仍然想知道发生了什么。
关于c++ - boost::filesystem::last_write_time 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4343175/