2010-12-03 306 views
4

這是我收到的鏈接器錯誤。我的所有其他boost :: filesystem事情正在解決。我不明白爲什麼這個沒有。我認爲這是一個提升1.40的問題,所以我升級到1.44,問題依然存在。我正在使用#define BOOST_FILESYSTEM_VERSION 3,但我看不到在這種情況下沒有提供last_write_time。儘管api部分存在,但似乎缺少底層實現。boost :: filesystem :: last_write_time在哪裏?

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 *)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@Z) referenced in function "void __cdecl boost::filesystem3::last_write_time(class boost::filesystem3::path const &,long)" ([email protected]@[email protected]@[email protected]@[email protected]) 

哦,是的,使用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)" ([email protected]@[email protected]@@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 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)" ([email protected][email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@@@[email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@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: 
+0

你鏈接到1.44版本還是1.40版本? – 2010-12-03 07:01:50

+0

與1.44鏈接,它似乎在兩個中斷,雖然我只升級到1.44後鏈接失敗1.40,但我確實修復了庫路徑。 – boatcoder 2010-12-03 07:23:26

回答

4

好的,問題很簡單,因爲它是鈍的。在VS2008及以上的時間是64位,除非你#define _USE_32_BIT_TIME_T。 boost庫的編譯沒有這個定義,因此它們的time_t是64位。我的項目由於一些遺留問題而定義_USE_32_BIT_TIME_T,因此會生成32位時間的API。

如果您生成的項目不使用32位時間,則按預期工作。

我很高興C++的員工足夠聰明,可以將呼叫簽名推入連接器中,並將其命名爲mangling。如果他們沒有這樣做,我仍然想知道發生了什麼。

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代替?