我想獲得一個簡單的例子與Boost.Timer一起工作的一些秒錶性能指標,我無法弄清楚爲什麼我無法成功鏈接Boost定時進入Boost.Chrono。我使用以下簡單腳本構建了源代碼提升鏈接器錯誤:Boost.Chrono Boost.Timer
.\b2 --clean
CALL bootstrap
.\b2 --build-type=complete address-model=64
但是仍然收到鏈接器錯誤。
70>libboost_timer-vc100-mt-1_49.lib(cpu_timer.obj) : error LNK2001: unresolved external symbol "public: static class boost::chrono::time_point<class boost::chrono::steady_clock,class boost::chrono::duration<__int64,class boost::ratio<1,1000000000> > > __cdecl boost::chrono::steady_clock::now(void)" ([email protected][email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected])
是否有必要實際上包括--with-chrono
標誌使用Timer類?找不到與定時器documentation相關的任何內容,儘管線程documentation似乎更多地提到了我從這個question引出的更多內容,這表明了鏈接修復的順序。
這有點令人困惑,因爲我看到通過項目設置Linker->General->Additional Library Directories
構建並準備好鏈接到Visual Studio中的程序集。我認爲Boost的設計在處理這些特定的庫方面並不明顯。任何人都可以評論這個嗎?與--with-chrono
/USES_CHRONO
宏有什麼關係,它似乎沒有阻止構建庫,所以它是否有條件地編譯出一些代碼,特別是time_point類?
我想根據表30.1。線程文檔中〜用於配置功能」即USES_CHRONO
是肯定的默認缺省值,因此我應該啓用這些功能吧?
C:\...\boost_binaries\msvc10_x64>dir /b | findstr /i chrono
boost_chrono-vc100-mt-1_49.dll
boost_chrono-vc100-mt-1_49.lib
boost_chrono-vc100-mt-gd-1_49.dll
boost_chrono-vc100-mt-gd-1_49.lib
libboost_chrono-vc100-mt-1_49.lib
libboost_chrono-vc100-mt-gd-1_49.lib
libboost_chrono-vc100-mt-s-1_49.lib
libboost_chrono-vc100-mt-sgd-1_49.lib
libboost_chrono-vc100-s-1_49.lib
libboost_chrono-vc100-sgd-1_49.lib
C:\...\boost_binaries\msvc10_x64>dir /b | findstr /i timer
boost_timer-vc100-mt-1_49.dll
boost_timer-vc100-mt-1_49.lib
boost_timer-vc100-mt-gd-1_49.dll
boost_timer-vc100-mt-gd-1_49.lib
libboost_timer-vc100-mt-1_49.lib
libboost_timer-vc100-mt-gd-1_49.lib
libboost_timer-vc100-mt-s-1_49.lib
libboost_timer-vc100-mt-sgd-1_49.lib
libboost_timer-vc100-s-1_49.lib
libboost_timer-vc100-sgd-1_49.lib
C:\...\boost_binaries\msvc10_x64>dir /b | findstr /i _system
boost_system-vc100-mt-1_49.dll
boost_system-vc100-mt-1_49.lib
boost_system-vc100-mt-gd-1_49.dll
boost_system-vc100-mt-gd-1_49.lib
libboost_system-vc100-mt-1_49.lib
libboost_system-vc100-mt-gd-1_49.lib
libboost_system-vc100-mt-s-1_49.lib
libboost_system-vc100-mt-sgd-1_49.lib
libboost_system-vc100-s-1_49.lib
libboost_system-vc100-sgd-1_49.lib
aha,我想我記得在工作期間有關Chrono是「僅頭文件」庫的內容。我不完全確定細節,但如果這是真的,那麼我可以看到包括頭是足夠的。 – jxramos