Find the answer to your Linux question:
Results 1 to 2 of 2
do_gettimeofday() - undefined reference 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> ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    1

    do_gettimeofday() - undefined reference

    do_gettimeofday() - undefined reference
    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

    [arpalla]$ uname -r
    2.6.30-2cse.0

    cat /etc/*release*
    Fedora release 11 (Leonidas)
    Fedora release 11 (Leonidas)
    Fedora release 11 (Leonidas)
    cpe:/o:fedoraproject:fedora:11

    Can anyone please help?

    Thanks,
    Anu

    PS - I have posted this earlier in redhat/fedora forum - but I figured out that this should be the apt forum - I will try to delete the thread there.. sorry for duplicating..

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    Try including the library with an -l (lower-case L) flag, the library location with an -L flag and the header location with an -I (upper-case i) flag in your compilation statement (see the man page for gcc for more details about these flags). I think the time library is not on the default path for the loader.
    Last edited by hazel; 10-04-2009 at 11:09 AM.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...