RE: clock_gettime() problem

From: Charlie Liu (
Date: Tue Apr 08 2003 - 18:20:23 EST

Any better mailing list you can point out for me so that I can post similar
question(s) in future?

Thanks for Mark's reply which fixed my problem.


-----Original Message-----
From: Randy.Dunlap []
Sent: Tuesday, April 08, 2003 3:58 PM
To: Charlie Liu
Subject: Re: clock_gettime() problem


I'm not quite sure why you are asking this question on the linux-net
mailing list. (?)

On Tue, 8 Apr 2003 15:30:03 -0700 "Charlie Liu" <>

| Hi All,
| Can anybody tell me what's the problem with my simple program calling
| clock_gettime() below.
| I have tried to compile the app under SuSE 8.1 & RedHad 7.2, but always
| error message like:
| In Function 'main': undefined reference to 'clock_gettime'
| It's defined in </usr/include/time.h>. Did I miss someting alse? How to
| it?

It's conditionally defined in that header file. Did you check to see if
the conditions are met?

| Thank you for any hit(s).
                or hints ? :)

Sure, my number one question: what kernel version?
The answer is not SuSE 8.1 or RH 7.2. It's something like
Linux 2.4.19 or Linux 2.5.60.

| --------------------------------------------------------------------------

| # gcc -o main main.c
| main.c:
| /*
|  * This program calculates the time required to
|  * execute the program specified as its first argument.
|  * The time is printed in seconds, on standard out.
|  */
| #define BILLION  1000000000L;

Lose that semi-colon there. ^

Linux 2.4.* does not implement the clock_gettime() syscall. Patches for 2.4 POSIX clocks and timers are available at

These syscalls were added to Linux 2.5.64 or thereabouts, so if you download a very recent Linux 2.5 kernel, you'll be able to use it for these syscalls. (more recent is better.)

-- ~Randy

- To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to More majordomo info at

This archive was generated by hypermail 2b29 : Tue Apr 15 2003 - 22:00:01 EST