Calling c shared library

simendsjo simendsjo at gmail.com
Fri Mar 23 07:04:48 PDT 2012


Forgive my programming 101 question :)

I want to call a method from a precompiled shared library:
// c header
void f(void);

// my d file
extern(C) void f();
void main() {}

$ dmd mydfile.d
libphobos2.a(deh2_33a_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

Is there a way to do the above, or do I have to manually load the shared  
library and use alias'es for the functions?


More information about the Digitalmars-d-learn mailing list