www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - phobos config issue

reply Radu Toev <radutoev gmail.com> writes:
Hello,

I am trying to config my environment to use phobos, but I'm having some
problems.
When I run dmd file.d I get the following error:

/usr/local/lib/lib32/libphobos2.a(datetime_3ac_1ec.o): In function
`_D3std8datetime5Clock11currStdTimeFNdNeZl':
std/datetime.d:(.text._D3std8datetime5Clock11currStdTimeFNdNeZl+0x1d):
undefined reference to `clock_gettime'
/usr/local/lib/lib32/libphobos2.a(time_c5_4d1.o): In function
`_D4core4time12TickDuration12_staticCtor7OFNeZv':
src/core/time.d:(.text._D4core4time12TickDuration12_staticCtor7OFNeZv+0x1b):
undefined reference to `clock_getres'
/usr/local/lib/lib32/libphobos2.a(time_c5_4d1.o): In function
`_D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration':
src/core/time.d:(.text._D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration+0x1c):
undefined reference to `clock_gettime'
collect2: ld returned 1 exit status

I googled around for some answers, but found nothing that helped.
Note: I have in my dmd.conf file the -L-lrt flag, but it doesn't seem to
work.

My OS is Ubuntu 32 bit.

Thanks.
Aug 27 2011
next sibling parent reply Vijay Nayar <madric gmail.com> writes:
On Sat, 27 Aug 2011 16:40:39 +0300, Radu Toev wrote:

There are two possibilities I can imagine:
  A.  The phobos2 library was somehow incomplete or not built correctly.
  To check this possibility, use the 'nm' command and search for the 
missing symbol.  I used the Ubuntu standard dmd package, so my 
directories may by slightly different.


$ nm /usr/lib64/librt.a | grep clock_gettime
clock_gettime.o:
0000000000000000 T clock_gettime

  B.  Another possibility is that the search path is bad?
Check your dmd.conf file and make sure that "-L-L/usr/local/lib/lib32" is 
part of the options under "DFLAGS".

I would personally recommend going with the pre-compiled Ubuntu package 
though.

 - Vijay
Aug 29 2011
parent Andrew Wiley <wiley.andrew.j gmail.com> writes:
On Mon, Aug 29, 2011 at 8:50 AM, Vijay Nayar <madric gmail.com> wrote:

 On Sat, 27 Aug 2011 16:40:39 +0300, Radu Toev wrote:

 There are two possibilities I can imagine:
  A.  The phobos2 library was somehow incomplete or not built correctly.
  To check this possibility, use the 'nm' command and search for the
 missing symbol.  I used the Ubuntu standard dmd package, so my
 directories may by slightly different.


 $ nm /usr/lib64/librt.a | grep clock_gettime
 clock_gettime.o:
 0000000000000000 T clock_gettime

  B.  Another possibility is that the search path is bad?
 Check your dmd.conf file and make sure that "-L-L/usr/local/lib/lib32" is
 part of the options under "DFLAGS".

 I would personally recommend going with the pre-compiled Ubuntu package
 though.
It's probably also worth checking whether it's actually using the dmd.conf that you think it's using (strace should do the trick). I don't know the search path list offhand, but it checks in quite a few places.
Aug 29 2011
prev sibling next sibling parent reply Radu Toev <radutoev gmail.com> writes:
Hi,

Thanks for the replies, I was away for a couple of days and I couldn't test
your proposals.
Sadly nothing seemed to work...I checked that the dmd.conf that I think it
was using was actually the one used and also that the DFLAG argument
-L-L/usr/local/lib/lib32 is present.
Running the nm command echos

nm: aio_read64.o: no symbols
nm: aio_write64.o: no symbols
nm: lio_listio64.o: no symbols
clock_gettime.o:
0000000000000000 T clock_gettime
nm: shm_unlink.o: no symbols

So I' currently stuck. :(

 On Sat, 27 Aug 2011 16:40:39 +0300, Radu Toev wrote:

 There are two possibilities I can imagine:
  A.  The phobos2 library was somehow incomplete or not built correctly.
  To check this possibility, use the 'nm' command and search for the
 missing symbol.  I used the Ubuntu standard dmd package, so my
 directories may by slightly different.


 $ nm /usr/lib64/librt.a | grep clock_gettime
 clock_gettime.o:
 0000000000000000 T clock_gettime

  B.  Another possibility is that the search path is bad?
 Check your dmd.conf file and make sure that "-L-L/usr/local/lib/lib32" is
 part of the options under "DFLAGS".

 I would personally recommend going with the pre-compiled Ubuntu package
 though.
It's probably also worth checking whether it's actually using the dmd.conf that you think it's using (strace should do the trick). I don't know the search path list offhand, but it checks in quite a few places.
Aug 29 2011
parent Vijay Nayar <madric gmail.com> writes:
On Tue, 30 Aug 2011 09:15:48 +0300, Radu Toev wrote:

Ok, so far so good.  We know that you have the librt library, and that it 
was compiled with the symbols that the compiler is complaining about.

Could you copy the contents of your 'dmd.conf' file?  If your setup is 
pretty simple, there should only be one.  Run:
 $ sudo updatedb
 $ locate dmd.conf

I think the only remaining possibility is that the order of the 'phobos2' 
and 'rt' libraries is off.  Normally when the linker is resolving 
symbols, it goes left to right, putting all unknown symbols in a bucket, 
and resolving them against subsequent objects to link.  Symbols that are 
unused are not linked, and when the final object is linked, all symbols 
must be resolved.

So in order to link together all these archives (.a as opposed to .so), 
make sure that '-L-lphobos2' comes BEFORE '-L-lrt' in the DFLAGS setting.

 - Vijay
Aug 30 2011
prev sibling parent mta`chrono <chrono mta-international.net> writes:
Try using "dmd -v file.d" to see what actually going on there.
Sep 24 2011