Using D libs in C

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 7 11:07:19 PST 2011


On Mon, 07 Feb 2011 13:53:14 -0500, spir <denis.spir at gmail.com> wrote:

> On 02/07/2011 04:32 PM, Steven Schveighoffer wrote:
>> On Mon, 07 Feb 2011 06:42:46 -0500, spir <denis.spir at gmail.com> wrote:
>>
>>> On 02/07/2011 07:53 AM, GreatEmerald wrote:
>>>> Hmm, no, it won't work right on Linux for some reason. This is the  
>>>> output:
>>>>
>>>> /usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../libphobos2.a(deh2_4e7_525.o):  
>>>> In
>>>> function `_D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable':
>>>> src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x4):
>>>>
>>>> undefined reference to `_deh_beg'
>>>> src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0xc):
>>>>
>>>> undefined reference to `_deh_beg'
>>>> src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x13):
>>>>
>>>> undefined reference to `_deh_end'
>>>> src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x37):
>>>>
>>>> undefined reference to `_deh_end'
>>>> collect2: ld returned 1 exit status
>>>> --- errorlevel 1
>>>>
>>>> The shell script I'm using to compile it is:
>>>>
>>>> #!/bin/sh
>>>> dmd -m32 -c -lib dpart.d
>>>> gcc -m32 -c cpart.c
>>>> dmd -m32 cpart.o dpart.a /usr/lib/libphobos2.a
>>>>
>>>> (Although it appears that you don't need to explicitly link with  
>>>> libphobos2, it
>>>> does it automatically... and fails with the above error.) Any ideas  
>>>> about
>>>> what the
>>>> error means?
>>>
>>> Take my words with much doubt, I've few exp in that.
>>> Are you sure you did use same source under both OSes?
>>> "undefined reference to `_deh_end' / `_deh_beg'"
>>
>> deh == d exception handling (or handler, not sure) ;)
>>
>> Looks like the module that's failing to link is rt.deh
>
> Are you sure of that? I get exactly the same kind of linker error when  
> forgetting a fake main(){} (whatver the number of modules). Eg:
> 	...
> 	src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0xc):  
> undefined reference to `_deh_beg'
> 	src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x13):  
> undefined reference to `_deh_end'
> 	...
> repeted n times.

Hm... it looks like _deh_beg and _deh_end is something defined by the  
compiler?  It's used in deh2.d but not defined anywhere in druntime.

I'm pretty sure deh stands for d exception handler.

-Steve


More information about the Digitalmars-d-learn mailing list