Where is boost :: filesystem :: last_write_time?

This is the linker error I get. Everything else from my boost :: filesystem stuff is allowed. I do not understand why this is not. I thought this was a problem with boost 1.40, so I upgraded to 1.44 and the problem remained. I am using #define BOOST_FILESYSTEM_VERSION 3 , but I do not see mention that last_write_time is not provided in this case. It seems that the main implementation is missing, although part of the api is present.

 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 yes, using Windows VS2008.

Used code:

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

Anyone else come across this?

And this happens with #define BOOST_FILESYSTEM_VERSION 2 . The Boost libraries I use are boostpro (pre-built, yes, I'm lazy)

 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

 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: 
+4
source share
2 answers

Well, the problem is as simple as dumb. In VS2008 and above, time_t is 64 bits unless you are #define _USE_32_BIT_TIME_T . Acceleration libraries are compiled without this definition, and therefore time_t has 64 bits for them. Due to some obsolete problems, my project defines _USE_32_BIT_TIME_T and therefore generates an API with 32-bit time.

If you create a project that does not use 32-bit time, it works as expected.

I'm glad the C ++ guys were smart enough to push the call signature to the linker using mangling. If they hadn’t done this, I would still be interested in what is happening.

+4
source

I wonder if this is the problem with the function, as with the arguments of the function. Looking through boost :: filesystem api, I could not find the last_write_detail function with the Path and time arguments, only the Path argument. On the other hand, I found

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

Unlike

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

So, perhaps the error is because the linker cannot find the version of the function with the correct signature, and instead you should use last_write_time_ap?

0
source

All Articles