Re: building something with nanotime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Stapleton wrote:

> FreeBSD
> ========================================
> [sjss@elrond ~/dev/numbench]$ gcc numbench.c
> /var/tmp//ccnZ4l7C.o(.text+0x155c): In function `loop_calibrate':
> : undefined reference to `nanotime'
> /var/tmp//ccnZ4l7C.o(.text+0x15b6): In function `loop_calibrate':
> : undefined reference to `nanotime'
> /var/tmp//ccnZ4l7C.o(.text+0x15ec): In function `iterbenchI':
> : undefined reference to `nanotime'
> /var/tmp//ccnZ4l7C.o(.text+0x165d): In function `iterbenchI':
> : undefined reference to `nanotime'
> /var/tmp//ccnZ4l7C.o(.text+0x1694): In function `iterbenchF':
> : undefined reference to `nanotime'
> /var/tmp//ccnZ4l7C.o(.text+0x1705): more undefined references to
> `nanotime' follow
> ========================================

On FreeBSD this is a kernel mode interface, not available to userspace. 
That is why the manpage is in section 9.  So you can't call this
function from a normal program.

> Cygwin:
> ========================================
> $ gcc numbench.c -lc -lm
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x2b4):
> undefined reference to `_srandomdev'
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x13ef):
> undefined reference to `_nanotime'
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x1445):
> undefined reference to `_nanotime'
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x1478):
> undefined reference to `_nanotime'
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x14e5):
> undefined reference to `_nanotime'
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x1518):
> undefined reference to `_nanotime'
> /cygdrive/c/DOCUME~1/STAPLE~1/LOCALS~1/Temp/ccSqoE54.o:numbench.c:(.text+0x1585):
> more undefined references to `_nanotime' follow
> collect2: ld returned 1 exit status
> ========================================

Cygwin does not provide the nanotime function.

> I tried adding a few libraries that might be useful:  -lc -lm -lmd
> -lpthread, but with no luck. I figured I'd try to find what library it
> is in, but couldn't (strings /lib/* | grep nano; string /usr/lib/* |
> grep nano). I could only find nanosleep, and a few other non-nanotime
> references.

The problem is that you're expecting to be able to use a nonstandard
function where it does not exist.  I think you need to switch APIs if
you want to build your code on these platforms.  gettimeofday(2) should
give you microsecond resolution and is POSIX standard.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux