Calling D function from C

Jonathan Crapuchettes jcrapuchettes at gmail.com
Wed Apr 23 11:16:12 PDT 2008


I just tried the following and it worked.

gcc -c main.c
gdmd test.d main.o

Thanks for everyones help!
JC

BCS wrote:
> Jonathan Crapuchettes wrote:
>> /usr/lib/gcc/x86_64-linux-gnu/4.1.3/../../../../lib32/libphobos.a(deh2.o): 
>> In function `_D4deh213__eh_finddataFPvZPS4deh213DHandlerTable':
>> internal/deh2.d:(.text._D4deh213__eh_finddataFPvZPS4deh213DHandlerTable+0x9): 
>> undefined reference to `_deh_beg'
>> internal/deh2.d:(.text._D4deh213__eh_finddataFPvZPS4deh213DHandlerTable+0xe): 
>> undefined reference to `_deh_beg'
>> internal/deh2.d:(.text._D4deh213__eh_finddataFPvZPS4deh213DHandlerTable+0x14): 
>> undefined reference to `_deh_end'
>> internal/deh2.d:(.text._D4deh213__eh_finddataFPvZPS4deh213DHandlerTable+0x37): 
>> undefined reference to `_deh_end'
>> collect2: ld returned 1 exit status
>>
>> Jarrett Billingsley wrote:
>>
>>> "Jonathan Crapuchettes" <jcrapuchettes at gmail.com> wrote in message 
>>> news:fulp5j$19hu$1 at digitalmars.com...
>>>
>>>> /opt/dmd/bin/dmd test.d -c
>>>> gcc main.c test.o -m32 -o tester -lphobos -lpthread -lm
>>>> Linker Error...
>>>
>>>
>>> What _was_ the linker error?
>>>
> 
> `_deh_beg' & `_deh_end' (or should that be da_beg & da_end) are IIRC 
> part of the runtime. Try deleting all the .o files and then running it 
> the other way (gcc -c main.c; dmd test.d main.o) dmd sometimes has 
> issues with stuff if you compile piecemeal. There might be other ways to 
> fix this but I don't recall the details.


More information about the Digitalmars-d-learn mailing list