www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using DLL

reply Zarathustra <adam.chrapkowski gmail.com> writes:
I created lib file:
implib /s zlib.lib zlib.dll
and:
zlib.d
but when I tryed compile:
dmd main.d zlib.d zlib.lib
in main.d is import zlib.d
I got some errors:
 main.obj(main)
 Error 42: Symbol Undefined _D4zlib10deflateEndFPS4zlib8z_streamZi
main.obj(main)
 Error 42: Symbol Undefined _D4zlib7deflateFPS4zlib8z_streamiZi
main.obj(main)
 Error 42: Symbol Undefined _D4zlib10inflateEndFPS4zlib8z_streamZi
main.obj(main)
 Error 42: Symbol Undefined _D4zlib7inflateFPS4zlib8z_streamiZi
zlib.obj(zlib)
 Error 42: Symbol Undefined _D4zlib13deflateInit2_FPS4zlib8z_streamiiiiiPaiZi
zlib.obj(zlib)
 Error 42: Symbol Undefined _D4zlib13inflateInit2_FPS4zlib8z_streamiPaiZi
zlib.obj(zlib)
 Error 42: Symbol Undefined _D4zlib16inflateBackInit_FPS4zlib8z_streamiPhPaiZi
zlib.obj(zlib)
 Error 42: Symbol Undefined _D4zlib12inflateInit_FPS4zlib8z_streamPaiZi
zlib.obj(zlib)
 Error 42: Symbol Undefined _D4zlib12deflateInit_FPS4zlib8z_streamiPaiZi
--- errorlevel 9

I don't know what is wrong, that zlib isn't linked.
Apr 24 2008
parent reply torhu <no spam.invalid> writes:
Zarathustra wrote:
 I created lib file:
 implib /s zlib.lib zlib.dll
 and:
 zlib.d
 but when I tryed compile:
 dmd main.d zlib.d zlib.lib
 in main.d is import zlib.d
 I got some errors:
  main.obj(main)
  Error 42: Symbol Undefined _D4zlib10deflateEndFPS4zlib8z_streamZi
 main.obj(main)
  Error 42: Symbol Undefined _D4zlib7deflateFPS4zlib8z_streamiZi
 main.obj(main)
  Error 42: Symbol Undefined _D4zlib10inflateEndFPS4zlib8z_streamZi
 main.obj(main)
  Error 42: Symbol Undefined _D4zlib7inflateFPS4zlib8z_streamiZi
 zlib.obj(zlib)
  Error 42: Symbol Undefined _D4zlib13deflateInit2_FPS4zlib8z_streamiiiiiPaiZi
 zlib.obj(zlib)
  Error 42: Symbol Undefined _D4zlib13inflateInit2_FPS4zlib8z_streamiPaiZi
 zlib.obj(zlib)
  Error 42: Symbol Undefined _D4zlib16inflateBackInit_FPS4zlib8z_streamiPhPaiZi
 zlib.obj(zlib)
  Error 42: Symbol Undefined _D4zlib12inflateInit_FPS4zlib8z_streamPaiZi
 zlib.obj(zlib)
  Error 42: Symbol Undefined _D4zlib12deflateInit_FPS4zlib8z_streamiPaiZi
 --- errorlevel 9
 
 I don't know what is wrong, that zlib isn't linked.
 

If zlib.d contains prototypes of the C functions, you have to declare them 'extern (C)'. Try putting 'extern (C):' at the top of the file. Phobos includes bindings for zlib, you could try those instead. I don't know what you need to do to use them, though.
Apr 24 2008
parent Zarathustra <adam.chrapkowski gmail.com> writes:
Great it's working thank You very much.
I salute!
Apr 24 2008