LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-28-2006, 06:04 PM   #1
AndreiCiprian
LQ Newbie
 
Registered: Nov 2005
Location: Bucharest
Distribution: Ubuntu
Posts: 6

Rep: Reputation: 0
clock_gettime() issue


My current homework is to compare execution times of the Boyer-Moore, Knuth-Morris-Pratt and Rabin-Karp algorithms.
Since the search is pretty fast I thought of using clock_gettime() so nanoseconds will be returned.
Code:
        struct timespec *ts;	
	t = clock_gettime(CLOCK_REALTIME, ts);
	printf("clock_gettime returns:\n");
	printf("%d seconds and %ld nanoseconds\n", ts->tv_sec, ts->tv_nsec);
When I compile I get the message:
Code:
system_time.c:(.text+0x43): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
I have included <time.h>, and checked for the existence of clock_gettime() there.

Sorry for double posting, I tried
Code:
gcc -lrt -o time time.c
and it worked.

It seems that some types needed for the call are located in librt

Last edited by AndreiCiprian; 03-29-2006 at 03:31 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
POSIX.4 clock_gettime function collinss Programming 2 09-13-2005 06:55 AM
Slack 10.1 -- Mouse issue / X11 issue Pozican Linux - General 4 04-19-2005 03:44 AM
webmin issue, poss security issue bejiita Slackware 3 11-03-2004 06:07 AM
Having Issue w/ Truetype fonts - Mozilla Issue clove Linux - Software 4 02-18-2004 08:26 AM
POSIX.4 clock_gettime function collinss Linux - General 1 11-24-2003 12:12 PM


All times are GMT -5. The time now is 08:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration