I'm trying to compile this simple program to start learning how to use timers:
#include <boost/timer.hpp>
using boost::timer::cpu_timer;
//...
nanosecond_type last_checkpoint_time = 0;
cpu_timer checkpoint_timer; // start the timer
for (;;)
{
//process_a_transaction();
if (checkpoint_timer.elapsed().user - last_checkpoint_time > 5*1000000000LL)
{
//... create a checkpoint ...
last_checkpoint_time = checkpoint_timer.elapsed().user;
cout << checkpoint_timer.elapsed().user << endl;
}
}
I'm using gentoo linux and issuing the following command to compile:
g++ -I /usr/include/boost-1_46 timer1.cpp -o timer
I get these errors:
timer1.cpp:3:21: error: ‘boost::timer::cpu_timer’ has not been declared
timer1.cpp:5:1: error: ‘nanosecond_type’ does not name a type
timer1.cpp:6:1: error: ‘cpu_timer’ does not name a type
timer1.cpp:8:1: error: expected unqualified-id before ‘for’
timer1.cpp:8:8: error: expected unqualified-id before ‘)’ token
I was reading the docs under errors and warnings but the problem I am having is that I only have two libraries:
/usr/lib/libboost_test_exec_monitor-1_46.a
/usr/lib/libboost_test_exec_monitor-mt-1_46.a
Is this because I did not use the static-libs flag during compile of boost? Would I be better off using static-libs? Maybe this is a tangent. What else can cause the errors given above? Please forgive my ignorance as I am pretty new to C++/boost.
Thanks