Using D libs in C

spir denis.spir at gmail.com
Mon Feb 7 03:42:46 PST 2011


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'"
(read: "D-begin" / "D-end" I guess, looks like Pascal slang ;-) is nicely 
output by the linker when your "main" module does not have a main(). (There is 
a similar error when an imported module has a main(), eg for testing, so that 
the linker finds 2 of them.) Did you change something before compiling under 
Linux? Or does this pseudo-error happen only under Linux?
Add an empty main() to your top module, and tell us...

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list