[chrono] Help need for Linux implementation

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; }

On Mon, Nov 10, 2008 at 5:39 PM, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
Thanks! I'd actually tried that, but used -llibrt. But with your confirmation that librt was the library needed, I eventually tried -lrt and it worked. I guess dropping the "lib" prefix is something everyone (except me!) knows. --Beman
participants (2)
-
Beman Dawes
-
Sebastian Redl