This return appears to not be created anywhere (I don't know, just my opinion), hence the unresolved external.
I tried to fix this several ways and the simplest one was to just #include a boost file as below:
> #include <boost/chrono/chrono.hpp>
> And, it works!!
>> why does adding an include fix the problem?
May have something to do with indirectly including boost/chrono/config.hpp
which defines a bunch of preprocessor symbols and then includes boost/config/auto_link.hpp
Which has this comment at the top:
1 2 3 4 5 6
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE auto_link.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers.
*/
Boost Chrono is not 'header-only', have you tried explicitly linking with the library?
I tried to explicitly link the library but without the #include the error is the same - actually it makes sense because the linker error mentions the library (so it was linking the library since the start). See, the error message was:
1>libboost_timer-vc141-mt-gd-1_64.lib(cpu_timer.obj) : error LNK2019: 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) referenced in function "void __cdecl `anonymous namespace'::get_cpu_times(struct boost::timer::cpu_times &)" (?get_cpu_times@?A0x4cf65ba4@@YAXAEAUcpu_times@timer@boost@@@Z)
So, this library itself must have a link dependency that is added automatically when we:
#include <boost/chrono/chrono.hpp>
is there a map of link dependencies between the libraries of boost 1.64?
I was linking to the appropriate version... but your suggestion made me look into auto_link.hpp and I learned more about the encoding of boost libraries for Microsoft compilers so Thanks!
Also, my hunch that the problem was another library missing was correct. I found the missing library by
#define BOOST_LIB_DIAGNOSTIC
and watching the linked libraries. It turns out that the chrono library depends on the system library!
BTW I looked up tools for finding component/libraries interdependencies in boost and came across a very interesting tool written by YT Kanalseite called Boost Dependency Analyzer in July 22, 2013.
Could not get it to work with Boost 1.64.0... probably related to the fact that the building with Visual Studio 2017 is broken (I had to download the prebuilt binaries) and the binaries I downloaded were 64 bit - whereas the bcp.exe was 32 bit (which is the only version that will compiler with VS 2017)...
Many thanks as always and specially for making me do some extra work!