Thread overview
Unable to get Phobos working on Ubuntu x64 (Oneiric)
Sep 16, 2011
Kiith-Sa
Sep 16, 2011
Jonathan M Davis
Sep 16, 2011
Kiith-Sa
Sep 18, 2011
Jonathan M Davis
Oct 14, 2011
Matt Soucy
Oct 14, 2011
Justin Whear
September 16, 2011
I've just installed a new system - Ubuntu 11.10 beta x64 and can't get dmd/phobos 2.055 to work.

When I try to compile file hello.d with the following content:

import std.stdio;

void main()
{
    writeln("Hello World!");
}


I get this error:

/usr/lib/gcc/x86_64-linux-
gnu/4.6.1/../../../../lib/libphobos2.a(datetime_48b_1ec.o): In function
`_D3std8datetime5Clock11currStdTimeFNdNeZl':
std/datetime.d:(.text._D3std8datetime5Clock11currStdTimeFNdNeZl+0x1d):
undefined reference to `clock_gettime'
/usr/lib/gcc/x86_64-linux-
gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
`_D4core4time12TickDuration12_staticCtor7OFNeZv':
src/core/time.d:(.text._D4core4time12TickDuration12_staticCtor7OFNeZv+0x1f):
undefined reference to `clock_getres'
/usr/lib/gcc/x86_64-linux-
gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
`_D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration':
src/core/time.d:
(.text._D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration+0x1f):
undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
--- errorlevel 1


Nothing else using Phobos compiles either.

I've seen previous related threads. Tried -L-lrt, didn't work.
I tried the .deb package for Ubuntu, the binaries shipped
in the source archive, as well as compiling Phobos myself (removing
DMD/Phobos every time to make sure no files persisted), but nothing helped.


Has anyone encountered this problem? Did anyone get it to work on Ubuntu (especially 11.10)?
September 16, 2011
On Friday, September 16, 2011 12:47 Kiith-Sa wrote:
> I've just installed a new system - Ubuntu 11.10 beta x64 and can't get dmd/phobos 2.055 to work.
> 
> When I try to compile file hello.d with the following content:
> 
> import std.stdio;
> 
> void main()
> {
> writeln("Hello World!");
> }
> 
> 
> I get this error:
> 
> /usr/lib/gcc/x86_64-linux-
> gnu/4.6.1/../../../../lib/libphobos2.a(datetime_48b_1ec.o): In function
> `_D3std8datetime5Clock11currStdTimeFNdNeZl':
> std/datetime.d:(.text._D3std8datetime5Clock11currStdTimeFNdNeZl+0x1d):
> undefined reference to `clock_gettime'
> /usr/lib/gcc/x86_64-linux-
> gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
> `_D4core4time12TickDuration12_staticCtor7OFNeZv':
> src/core/time.d:(.text._D4core4time12TickDuration12_staticCtor7OFNeZv+0x1f)
> : undefined reference to `clock_getres'
> /usr/lib/gcc/x86_64-linux-
> gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
> `_D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration'
> : src/core/time.d:
> (.text._D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDur
> ation+0x1f): undefined reference to `clock_gettime'
> collect2: ld returned 1 exit status
> --- errorlevel 1
> 
> 
> Nothing else using Phobos compiles either.
> 
> I've seen previous related threads. Tried -L-lrt, didn't work.
> I tried the .deb package for Ubuntu, the binaries shipped
> in the source archive, as well as compiling Phobos myself (removing
> DMD/Phobos every time to make sure no files persisted), but nothing helped.
> 
> 
> Has anyone encountered this problem? Did anyone get it to work on Ubuntu
> (especially 11.10)?

It's clearly an issue where it can't find librt, since clock_gettime is in librt. As long as you didn't mess with dmd.conf, -L-lrt should already be given to the compiler, but regardless, if you passed it yourself, it should work.

Are you using a 64-bit binary of dmd or a 32-bit binary? If you're using a 32- bit binary (or building for 32-bit with a 64-bit binary), then you're going to need the 32-bit libraries for glibc, pthreads, and librt (I don't know what packages those are on Ubuntu, but if you have the 32-bit libraries installed at all, odds are that those ones are there).

- Jonathan M Davis
September 16, 2011
Jonathan M Davis wrote:

> On Friday, September 16, 2011 12:47 Kiith-Sa wrote:
>> I've just installed a new system - Ubuntu 11.10 beta x64 and can't get dmd/phobos 2.055 to work.
>> 
>> When I try to compile file hello.d with the following content:
>> 
>> import std.stdio;
>> 
>> void main()
>> {
>> writeln("Hello World!");
>> }
>> 
>> 
>> I get this error:
>> 
>> /usr/lib/gcc/x86_64-linux-
>> gnu/4.6.1/../../../../lib/libphobos2.a(datetime_48b_1ec.o): In function
>> `_D3std8datetime5Clock11currStdTimeFNdNeZl':
>> std/datetime.d:(.text._D3std8datetime5Clock11currStdTimeFNdNeZl+0x1d):
>> undefined reference to `clock_gettime'
>> /usr/lib/gcc/x86_64-linux-
>> gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
>> `_D4core4time12TickDuration12_staticCtor7OFNeZv':
>> src/core/time.d:
(.text._D4core4time12TickDuration12_staticCtor7OFNeZv+0x1f)
>> : undefined reference to `clock_getres' /usr/lib/gcc/x86_64-linux- gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
>> 
`_D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration'
>> : src/core/time.d:
>> 
(.text._D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDur
>> ation+0x1f): undefined reference to `clock_gettime' collect2: ld returned 1 exit status
>> --- errorlevel 1
>> 
>> 
>> Nothing else using Phobos compiles either.
>> 
>> I've seen previous related threads. Tried -L-lrt, didn't work.
>> I tried the .deb package for Ubuntu, the binaries shipped
>> in the source archive, as well as compiling Phobos myself (removing
>> DMD/Phobos every time to make sure no files persisted), but nothing
>> helped.
>> 
>> 
>> Has anyone encountered this problem? Did anyone get it to work on Ubuntu
>> (especially 11.10)?
> 
> It's clearly an issue where it can't find librt, since clock_gettime is in librt. As long as you didn't mess with dmd.conf, -L-lrt should already be given to the compiler, but regardless, if you passed it yourself, it should work.
> 
> Are you using a 64-bit binary of dmd or a 32-bit binary? If you're using a 32- bit binary (or building for 32-bit with a 64-bit binary), then you're going to need the 32-bit libraries for glibc, pthreads, and librt (I don't know what packages those are on Ubuntu, but if you have the 32-bit libraries installed at all, odds are that those ones are there).
> 
> - Jonathan M Davis

I'm using the 64bit binary. DMD uses the following to link (from verbose output):

gcc hello.o -o hello -m64 -Xlinker -L/usr/lib64 -Xlinker -L/usr/lib32 - Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt -lphobos2 - lpthread -lm

librt.so is present in /usr/lib/x86_64-linux-gnu , also copied it to /usr/lib . Still the same error.
September 18, 2011
On Friday, September 16, 2011 23:15:16 Kiith-Sa wrote:
> Jonathan M Davis wrote:
> > On Friday, September 16, 2011 12:47 Kiith-Sa wrote:
> >> I've just installed a new system - Ubuntu 11.10 beta x64 and can't get dmd/phobos 2.055 to work.
> >> 
> >> When I try to compile file hello.d with the following content:
> >> 
> >> import std.stdio;
> >> 
> >> void main()
> >> {
> >> writeln("Hello World!");
> >> }
> >> 
> >> 
> >> I get this error:
> >> 
> >> /usr/lib/gcc/x86_64-linux-
> >> gnu/4.6.1/../../../../lib/libphobos2.a(datetime_48b_1ec.o): In
> >> function
> >> `_D3std8datetime5Clock11currStdTimeFNdNeZl':
> >> std/datetime.d:(.text._D3std8datetime5Clock11currStdTimeFNdNeZl+0x1d):
> >> undefined reference to `clock_gettime'
> >> /usr/lib/gcc/x86_64-linux-
> >> gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
> >> `_D4core4time12TickDuration12_staticCtor7OFNeZv':
> 
> >> src/core/time.d:
> (.text._D4core4time12TickDuration12_staticCtor7OFNeZv+0x1f)
> 
> >> : undefined reference to `clock_getres'
> >> 
> >> /usr/lib/gcc/x86_64-linux-
> >> gnu/4.6.1/../../../../lib/libphobos2.a(time_c0_4d1.o): In function
> 
> `_D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration'
> 
> >> : src/core/time.d:
> (.text._D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDur
> 
> >> ation+0x1f): undefined reference to `clock_gettime' collect2: ld returned 1 exit status
> >> --- errorlevel 1
> >> 
> >> 
> >> Nothing else using Phobos compiles either.
> >> 
> >> I've seen previous related threads. Tried -L-lrt, didn't work.
> >> I tried the .deb package for Ubuntu, the binaries shipped
> >> in the source archive, as well as compiling Phobos myself (removing
> >> DMD/Phobos every time to make sure no files persisted), but nothing
> >> helped.
> >> 
> >> 
> >> Has anyone encountered this problem? Did anyone get it to work on
> >> Ubuntu
> >> (especially 11.10)?
> > 
> > It's clearly an issue where it can't find librt, since clock_gettime is in librt. As long as you didn't mess with dmd.conf, -L-lrt should already be given to the compiler, but regardless, if you passed it yourself, it should work.
> > 
> > Are you using a 64-bit binary of dmd or a 32-bit binary? If you're using a 32- bit binary (or building for 32-bit with a 64-bit binary), then you're going to need the 32-bit libraries for glibc, pthreads, and librt (I don't know what packages those are on Ubuntu, but if you have the 32-bit libraries installed at all, odds are that those ones are there).
> > 
> > - Jonathan M Davis
> 
> I'm using the 64bit binary. DMD uses the following to link (from verbose
> output):
> 
> gcc hello.o -o hello -m64 -Xlinker -L/usr/lib64 -Xlinker -L/usr/lib32 - Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt -lphobos2 - lpthread -lm
> 
> librt.so is present in /usr/lib/x86_64-linux-gnu , also copied it to /usr/lib . Still the same error.

librt.a is needed as well, so maybe that's the problem. /usr/lib/x86_64-linux- gnu strikes me as a weird place to put it regardless. You should probably check whether it's in your linker's path. If so, it should be listed in /etc/ld.so.conf.

If librt.a is clearly in the linker's path, then I'd try just downloading the dmd zip file, unzipping it, adding /path/to/unzipped/dmd2/linux/bin/ to your path before wherever the installed dmd is (or adding it to your wherever in your path and uninstall the installed dmd) and seeing whether that works. I would hope that that wouldn't be necessary though.

But clearly, the linker is not finding librt, and that's what needs to be fixed. I'm not an Ubuntu user though, so I don't know exactly what Ubuntu does differently or how dmd is installed with the .deb file. Personally, I've always use the zip file without trying to install dmd with the package manager or move any of its associated tools or libraries into /usr/ or /usr/local.

- Jonathan M Davis
October 14, 2011
I know this is slightly old, but I didn't see a solution - I decided, in a fit of
madness, to attempt a Day 1 upgrade from Natty to Oneiric. It...didn't exactly
work, and I ended up with this same problem.
It's apparently not a problem with x64, since I'm using x86 Ubuntu. (I grabbed the
wrong disk before I installed...)
I somehow have/had (I downgraded so I could work properly again) a /usr/lib64
folder. I'm not exactly an expert in Linux filesystems, or even anywhere near
close, but it seems that I shouldn't have had that on a x86 install. I had the
files librt.a and librt.so in there, but even desperately symlinking them into the
proper location didn't help.
This problem is rather irritating - has anyone upgraded successfully, and actually
had it work? I would definitely like to upgrade to 11.10, but I don't want to have
to halt all code development when I do.
Thank you,
-Matt Soucy
October 14, 2011
I tore my hair out over this before I examined the gcc line run by dmd, and found that -lphobos2 was being dropped in after -lrt. The simple fix is to modify your dmd.conf (build something with dmd -v to see where this is) such that "-L-lphobos2" is added BEFORE "-L-lrt".

Justin



Matt Soucy wrote:

> I know this is slightly old, but I didn't see a solution - I decided, in a
> fit of madness, to attempt a Day 1 upgrade from Natty to Oneiric.
> It...didn't exactly work, and I ended up with this same problem.
> It's apparently not a problem with x64, since I'm using x86 Ubuntu. (I
> grabbed the wrong disk before I installed...)
> I somehow have/had (I downgraded so I could work properly again) a
> /usr/lib64 folder. I'm not exactly an expert in Linux filesystems, or even
> anywhere near close, but it seems that I shouldn't have had that on a x86
> install. I had the files librt.a and librt.so in there, but even
> desperately symlinking them into the proper location didn't help.
> This problem is rather irritating - has anyone upgraded successfully, and
> actually had it work? I would definitely like to upgrade to 11.10, but I
> don't want to have to halt all code development when I do.
> Thank you,
> -Matt Soucy