LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-09-2009, 03:56 PM   #1
fardad
LQ Newbie
 
Registered: Apr 2008
Posts: 11

Rep: Reputation: 0
how to get the current time with nano seconds on a linux box using c++


Hi --
I need to know how to get the current time with nano seconds on a linux box using c++?

thanks in advance.
 
Old 01-09-2009, 04:21 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by fardad View Post
Hi --
I need to know how to get the current time with nano seconds on a linux box using c++?

thanks in advance.
Try this:

Code:
#include <sys/time.h>

int main()
{
   timespec ts;
   clock_gettime(CLOCK_REALTIME, &ts);
}
 
Old 01-09-2009, 06:00 PM   #3
fardad
LQ Newbie
 
Registered: Apr 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thank you.

I tried but I am getting "undefined refrence to 'clock_gettime()'. I see someother people have the same issue. I read in another thread :
http://www.linuxquestions.org/questi...roblem-390051/

that I should include with -lrt. Could you help me undresntad this? should I include this in mu make file?
 
Old 01-09-2009, 09:29 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,334

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
Here is an article that may help you:

http://lwn.net/Articles/167897/

------------------
Steve Stites
 
  


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
Setting time and time zone altogether properly in Slack-current, KDE4 spaceballs Slackware 3 04-20-2011 05:15 AM
VB, 30 seconds of your time, please? rhoyerboat Programming 2 02-27-2007 01:26 PM
LXer: Tiny WiFi-enabled Linux box boots in 1.1 seconds LXer Syndicated Linux News 0 10-11-2006 12:21 AM
get system time in mili-seconds how to onnyloh Programming 2 09-22-2004 01:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration