我正在尝试使用Boost.Timer进行一些停止性能测量的简单示例,我无法弄清楚为什么我无法将Boost.Timer成功链接到Boost.Chrono。我使用以下简单脚本
从源代码构建了boost.\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)" (?now@steady_clock@chrono@boost@@SA?AV?$time_point@Vsteady_clock@chrono@boost@@V?$duration@_JV?$ratio@$00$0DLJKMKAA@@boost@@@23@@23@XZ)
是否有必要实际包含--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