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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-09-2009, 03:56 PM
|
#1
|
LQ Newbie
Registered: Apr 2008
Posts: 11
Rep:
|
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.
|
|
|
01-09-2009, 04:21 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,717
|
Quote:
Originally Posted by fardad
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);
}
|
|
|
01-09-2009, 06:00 PM
|
#3
|
LQ Newbie
Registered: Apr 2008
Posts: 11
Original Poster
Rep:
|
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?
|
|
|
01-09-2009, 09:29 PM
|
#4
|
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,388
|
Here is an article that may help you:
http://lwn.net/Articles/167897/
------------------
Steve Stites
|
|
|
All times are GMT -5. The time now is 01:20 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|