linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Nanoseconds
@ 2005-08-24 19:08 r_zaca
  2005-08-24 19:29 ` Nanoseconds Steve Graegert
  0 siblings, 1 reply; 2+ messages in thread
From: r_zaca @ 2005-08-24 19:08 UTC (permalink / raw)
  To: linux-c-programming

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 840 bytes --]

  Hello all, 

  I need a way to get the date of my linux machine in seconds and 
nanoseconds. In seconds I know I can you some of the standards function of 
lib C (that give me the date since the "epoch"), but my problem is to get 
the nanoseconds. I was reading about clock_gettime. It seems to solve my 
problem, but when I try to compile and link it, I get an error message like 
that: 

cc     time.c   -o time 
/tmp/ccOKP0zk.o(.text+0x21): In function `main': 
: undefined reference to `clock_gettime' 
collect2: ld returned 1 exit status 
make: *** [time] Error 1 

I know its a linker error, that is, the linker doesn't not know here to find 
this function. 
Doesn't this function belong to the standard gnu libc? 
Have anyone heard about "clock_gettime"? If someone knows how it is 
implemented, I'd appreciate so much. 

Thanks. 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Nanoseconds
  2005-08-24 19:08 Nanoseconds r_zaca
@ 2005-08-24 19:29 ` Steve Graegert
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Graegert @ 2005-08-24 19:29 UTC (permalink / raw)
  To: r_zaca; +Cc: linux-c-programming

On 8/24/05, r_zaca <r_zaca@ig.com.br> wrote:
>   Hello all,
> 
>   I need a way to get the date of my linux machine in seconds and
> nanoseconds. In seconds I know I can you some of the standards function of
> lib C (that give me the date since the "epoch"), but my problem is to get
> the nanoseconds. I was reading about clock_gettime. It seems to solve my
> problem, but when I try to compile and link it, I get an error message like
> that:
> 
> cc     time.c   -o time
> /tmp/ccOKP0zk.o(.text+0x21): In function `main':
> : undefined reference to `clock_gettime'
> collect2: ld returned 1 exit status
> make: *** [time] Error 1
> 
> I know its a linker error, that is, the linker doesn't not know here to find
> this function.
> Doesn't this function belong to the standard gnu libc?

Yes, all the clock_* functions are in librt (/lib/librt.so.1) which is
part of glibc.  Try linking against librt.

Regards

	\Steve

--

Steve Graegert <graegerts@gmail.com>
Software Consultancy {C/C++ && Java && .NET}
Mobile: +49 (176)  21248869
Office: +49 (9131) 7126409

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-08-24 19:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-24 19:08 Nanoseconds r_zaca
2005-08-24 19:29 ` Nanoseconds Steve Graegert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).