|
Boost : |
Subject: [boost] [chrono] Help need for Linux implementation
From: Beman Dawes (bdawes_at_[hidden])
Date: 2008-11-10 17:35:11
I've got a boostified version of the C++0x <chrono> header working on
Windows, but need help for the Linux implementation.
I wrote a test program (see below). It compiles OK but gets a link failure:
/tmp/ccmT80bD.o: In function `clk()':
test.cpp:(.text+0x192): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
What am I doing wrong? The command I'm using is simply "g++
test.cpp". Ubuntu 8.04 with all updates applied.
Thanks,
--Beman
-------------------------------
#include <time.h>
#include <stdlib.h>
#include <errno.h>
#include <iostream>
unsigned long long clk()
{
timespec ts;
if ( clock_gettime( CLOCK_MONOTONIC, &ts ) )
{
std::cout << "errno " << errno << "\n";
exit(0);
}
return (unsigned long long)ts.tv_sec * 1000000000 + ts.tv_nsec;
}
int main()
{
std::cout << clk() << " nanoseconds\n";
return 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk