[Solved] ORB_SLAM Install Error: error: ‘std::chrono::monotonic_clock’ has not been declared

The reason for this problem is that there is a difference between the C++ versions.

Momotonic_clock is no longer available in C++11, there is steady_clock instead.

I got the solution from Stack Overflow.

So the author of orb-slam used ifdef in the code to determine the user’s C++ version:

#ifdef COMPILEDWITHC11
        std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
#else
        std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();
#endif
 
        //Pass the image to the SLAM system
        SLAM.TrackMonocular(im,tframe);
 
#ifdef COMPILEDWITHC11
        std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
#else
        std::chrono::monotonic_clock::time_point t2 = std::chrono::monotonic_clock::now();
#endif

But this part of monotonic_clock will still report an error!

If you report an error in this part, there is a high probability that your C++ is version 11, then we can actually delete this part of the judgment statement and keep only

std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
 
 //Pass the image to the SLAM system
 SLAM.TrackMonocular(im,tframe);
 
std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
 
//......

This part is fine. After deleting the code of monotonic_clock, it can be compiled normally!

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *