Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 18, 2011 datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
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@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? |
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kai Meyer | On Fri, 18 Feb 2011 16:38:19 +0000, Kai Meyer wrote: > 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@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? You have to link in librt. Pass the -L-lrt option to DMD and it should work. -Lars |
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad | Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :( |
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kai Meyer | On Friday, February 18, 2011 10:12:09 Kai Meyer wrote:
> Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :(
That should be in the dmd.conf in dmd.2.052.zip. If you're using an old dmd.conf, that would be the problem. Actually, I wouldn't have expected and old dmd.conf to work at all, since the directory structure for the lib folder(s) was changed due to the addition of 64-bit. So, I don't know what the deal with your setup is. Regardless, make sure that your current dmd.conf is either the most up-to-date on or at least based on it. Otherwise, you're going to be running into issues.
- Jonathan M Davis
|
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Fri, 18 Feb 2011 10:23:41 -0800, Jonathan M Davis wrote:
> On Friday, February 18, 2011 10:12:09 Kai Meyer wrote:
>> Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :(
>
> That should be in the dmd.conf in dmd.2.052.zip. If you're using an old dmd.conf, that would be the problem. Actually, I wouldn't have expected and old dmd.conf to work at all, since the directory structure for the lib folder(s) was changed due to the addition of 64-bit. So, I don't know what the deal with your setup is. Regardless, make sure that your current dmd.conf is either the most up-to-date on or at least based on it. Otherwise, you're going to be running into issues.
Well, he could be using a setup similar to me. I don't use dmd.conf at all. Instead I set the DFLAGS environment variable in the startup script of my shell. I think the new dependency should be noted in the changelog.
-Lars
|
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad | On Friday, February 18, 2011 11:43:22 Lars T. Kyllingstad wrote:
> On Fri, 18 Feb 2011 10:23:41 -0800, Jonathan M Davis wrote:
> > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote:
> >> Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :(
> >
> > That should be in the dmd.conf in dmd.2.052.zip. If you're using an old dmd.conf, that would be the problem. Actually, I wouldn't have expected and old dmd.conf to work at all, since the directory structure for the lib folder(s) was changed due to the addition of 64-bit. So, I don't know what the deal with your setup is. Regardless, make sure that your current dmd.conf is either the most up-to-date on or at least based on it. Otherwise, you're going to be running into issues.
>
> Well, he could be using a setup similar to me. I don't use dmd.conf at all. Instead I set the DFLAGS environment variable in the startup script of my shell. I think the new dependency should be noted in the changelog.
Probably, but I think that Andrei or Walter would have to be the one to do that. But dmd.conf has changed a fair bit with this release, and anyone who doesn't use dmd.conf (I have no idea why you wouldn't - it seems like you're just making life harder on yourself) is going to run into trouble.
However, in general, I don't think that dmd.conf changes have made it into the changelog, so that's nothing new. Walter probably assumes that you're going to use the provided dmd.conf and doesn't think about it.
- Jonathan M Davis
|
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | == Quote from Jonathan M Davis (jmdavisProg@gmx.com)'s article > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: > > Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :( > That should be in the dmd.conf in dmd.2.052.zip. If you're using an old > dmd.conf, that would be the problem. Actually, I wouldn't have expected and old > dmd.conf to work at all, since the directory structure for the lib folder(s) was > changed due to the addition of 64-bit. So, I don't know what the deal with your > setup is. Regardless, make sure that your current dmd.conf is either the most > up-to-date on or at least based on it. Otherwise, you're going to be running > into issues. > - Jonathan M Davis Ok, my dmd.conf that came with the download does not have it in there. The package doesn't claim ownership to /etc/dmd.conf. I removed the rpm package, deleted the old dmd.conf, and installed the rpm again, but the dmd.conf that was generated is exactly the same: [kai@worky ~]$ cat /etc/dmd.conf [Environment] DFLAGS= -I/usr/include/d/dmd/phobos -I/usr/include/d/dmd/druntime/import -L-L/usr/lib Should I just simply add "-L-lrt" to the dmd.conf for now? Or just put it in my make file? Why does the rpm not claim ownership of the config file?: [kai@worky ~]$ rpm -qf /etc/dmd.conf file /etc/dmd.conf is not owned by any package [kai@worky ~]$ rpm -ql dmd | grep dmd.conf /usr/share/man/man5/dmd.conf.5.gz Thanks for the fast replies! |
February 18, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kai Meyer | On Friday, February 18, 2011 12:29:40 Kai Meyer wrote: > == Quote from Jonathan M Davis (jmdavisProg@gmx.com)'s article > > > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: > > > Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :( > > > > That should be in the dmd.conf in dmd.2.052.zip. If you're using an old > > dmd.conf, that would be the problem. Actually, I wouldn't have expected > > and old dmd.conf to work at all, since the directory structure for the > > lib folder(s) was changed due to the addition of 64-bit. So, I don't > > know what the deal with your setup is. Regardless, make sure that your > > current dmd.conf is either the most up-to-date on or at least based on > > it. Otherwise, you're going to be running into issues. > > - Jonathan M Davis > > Ok, my dmd.conf that came with the download does not have it in there. The > package doesn't claim ownership to /etc/dmd.conf. I removed the rpm > package, deleted the old dmd.conf, and installed the rpm again, but the > dmd.conf that was generated is exactly the same: > [kai@worky ~]$ cat /etc/dmd.conf > > [Environment] > > DFLAGS= -I/usr/include/d/dmd/phobos -I/usr/include/d/dmd/druntime/import -L-L/usr/lib > > > Should I just simply add "-L-lrt" to the dmd.conf for now? Or just put it in my make file? > > Why does the rpm not claim ownership of the config file?: > [kai@worky ~]$ rpm -qf /etc/dmd.conf > file /etc/dmd.conf is not owned by any package > [kai@worky ~]$ rpm -ql dmd | grep dmd.conf > /usr/share/man/man5/dmd.conf.5.gz > > Thanks for the fast replies! If you just use the zip file, you're fine. I don't know what the state of the rpm is. I just always use the zip file. It's nice and self contained. All you have to do is make sure that /path/to/dmd2/linux/bin is on your PATH. The current dmd.conf should look like this: ======= [Environment] DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L- L%@P%/../lib32 -L-L%@P%/../lib64 -L--no-warn-search-mismatch -L--export-dynamic -L-lrt ======= If the pieces get moved elsewhere (such as installing libphobos2.a in a /usr/lib or something similar), then the paths would have to be updated though. Also, according to the online docs: ==== dmd will look for the initialization file dmd.conf in the following sequence of directories: 1. current working directory 2. directory specified by the HOME environment variable 3. directory dmd resides in 4. /etc/ ====== So, maybe you need to just put the correct dmd.conf in one of the first three spots. Or you could just edit /etc/dmd.conf. I don't know what exactly the rpm does, so I don't know what it does with dmd.conf. But you have several options. Really, -L-lrt _should_ be in dmd.conf since core.time and std.datetime require it, but ultimately what matters is that it be in your DFLAGS so that dmd uses it when compiling. - Jonathan M Davis |
February 19, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Attachments:
| As noted in my earlier email on the other list, I too got this problem. Fromn what I can tell 1.066 and 2.051 have dmd.conf files but there is no such thing in the 1.067 and 2.052 distributions. So the "out of the box" configuration does seem to be "broken". > That should be in the dmd.conf in dmd.2.052.zip. If you're using an old dmd.conf, that would be the problem. Actually, I wouldn't have expected and old dmd.conf to work at all, since the directory structure for the lib folder(s) was changed due to the addition of 64-bit. So, I don't know what the deal with your setup is. Regardless, make sure that your current dmd.conf is either the most up-to-date on or at least based on it. Otherwise, you're going to be running into issues. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
February 19, 2011 Re: datetime fails with undefined reference | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Sat, 2011-02-19 at 00:27 +0000, Russel Winder wrote: > As noted in my earlier email on the other list, I too got this problem. Fromn what I can tell 1.066 and 2.051 have dmd.conf files but there is no such thing in the 1.067 and 2.052 distributions. So the "out of the box" configuration does seem to be "broken". > > > That should be in the dmd.conf in dmd.2.052.zip. If you're using an old dmd.conf, that would be the problem. Actually, I wouldn't have expected and old dmd.conf to work at all, since the directory structure for the lib folder(s) was changed due to the addition of 64-bit. So, I don't know what the deal with your setup is. Regardless, make sure that your current dmd.conf is either the most up-to-date on or at least based on it. Otherwise, you're going to be running into issues. Sorry this is not correct, the locate database just hasn't been updated since I installeed. However the linux/bin/dmd.conf file is indentical in the 2.051 and 2.052 distributions. This means DMD is broken "out of the box". -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
Copyright © 1999-2021 by the D Language Foundation