c++ time.h, clock_gettime(), semantic error, how to link real-time library in Eclipse?
<p>I have some problem using the clock_gettime() function. </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;time.h&gt;

timespec timer_start;
timespec timer_end;

clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &amp;timer_start);
// sleep for 5 seconds
boost::this_thread::sleep(boost::posix_time::milliseconds(5000));
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &amp;timer_end);

std::cout &lt;&lt; (timer_end.tv_sec - timer_start.tv_sec) &lt;&lt; ":" &lt;&lt; (timer_end.tv_nsec - timer_start.tv_nsec) &lt;&lt; std::endl;
</code></pre>

<p>The output I get is this</p>

<p>0:6934599</p>

<p>It seems that the timer only elapsed 693 milliseconds or so. </p>

<p>I compile the program with g++ -lrt on Linux gnu gcc 4.6. I also received a Semantic Error, says
<strong>Symbol 'CLOCK_PROCESS_CPUTIME_ID' could not be resolved</strong> </p>

<p>Thanks.</p>
