Le Sunday 04 October 2009 à 00:22:41, vous avez écrit :
Hello:
I am new to linux and facing a simple compile problem. I have written a C
file which is using the do_gettimeofday() function.
#include <linux/time.h>
#include <stdio.h>
main()
{
struct timeval start;
do_gettimeofday(&start);
printf ("%d", start.tv_usec);
}
gcc a1.c --
undefined reference to `do_gettimeofday'
here is the PATH:
echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/
usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/homes/iws/arpalla/bin
I checked that the /usr/include/linux/time.h file got the function
declaration for do_gettimeofday()
Is there anything missing in the PATH variable?
I am facing same error for rdtscl() function as well!!
The Linux version is :
[arpalla]$ uname -a
Linux <..> 2.6.30-2.0 #6 SMP Mon Sep 21 11:03:44 PDT 2009 i686 i686 i386
GNU/Linux
Can anyone please help?
Thanks,
Anu
% man gettimeofday
NAME
gettimeofday, settimeofday - get / set time
SYNOPSIS
#include <sys/time.h>
int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tvtz);
DESCRIPTION
The functions gettimeofday() and settimeofday() can get and set the time as
well as a timezone. The tv argument is a struct timeval (as specified in
<sys/time.h>):
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
[...]
// getsecond.c
#include <sys/time.h>
#include <stdio.h>
main(void) {
struct timeval tv;
double t = 0.0;
if ( gettimeofday(&tv, NULL) != -1 )
t = tv.tv_usec / 1000000.0 + tv.tv_sec;
printf ("%f\n", t);
}
% gcc -O2 -s getsecond.c -o getsecond.bin
% ./getsecond.bin
1254613660.603762
+@
--
(o_
(/)_
S e r g e