datetime fails with undefined reference

Kai Meyer kai at fiber.net
Fri Feb 18 08:38:19 PST 2011


I can't seem to use std.datetime at all. I get undefined reference on whether
I use a StopWatch, or if I just try to compile the unittest. All I have to do
is declare a StopWatch:

import std.stdio;
import std.datetime;

void main()
{
    StopWatch sw;
}


This fails to compile:
[kai at worky ~]$ dmd datetime_test.d
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib/libphobos2.a(datetime_35c_30e.o):
In function `_D3std8datetime7systimeFNeZS3std8datetime5Ticks':
std/datetime.d:(.text._D3std8datetime7systimeFNeZS3std8datetime5Ticks+0x1c):
undefined reference to `clock_gettime'
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib/libphobos2.a(datetime_359_1fe.o):
In function `_D3std8datetime5Ticks12_staticCtor5OFNeZv':
std/datetime.d:(.text._D3std8datetime5Ticks12_staticCtor5OFNeZv+0x1b):
undefined reference to `clock_getres'
collect2: ld returned 1 exit status
--- errorlevel 1

Am I missing some libraries somewhere?

If I 'import core.sys.posix.time, core.sys.posix.sys.time;', parts of dattime
work, and others don't. A main with just:
    writef("%s %s\n", (is(typeof({auto fp = &clock_gettime; }))));

Prints "true true", but using them like this gives undefined again:
    timespec ts; writef("%d\n", clock_getres(CLOCK_REALTIME, &ts));


datetime_test.o: In function `_Dmain':
datetime_test.d:(.text._Dmain+0x34): undefined reference to `clock_getres'
collect2: ld returned 1 exit status
--- errorlevel 1


I'm running Fedora 14 x86_64, dmd-2.051-0.i386, glibc-2.13-1.i686.

Any ideas?


More information about the Digitalmars-d-learn mailing list