This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

__stdcall in 3rd-party dll



hi everyone !

after some diggin' in the mailing-list archives and on dejanews, i've
got some insight in the following situation, but still don't know how
to resolve it, perhaps somebody can give me a hit over the head with
the appropriate literature ;-)

i've got me a DLL (gpib-32.dll from national instruments), where i
want to link against some functions (ibdev, ibwrt, ibrd: perhaps
somebody's got that dll and wants to look for him/herself)

according to the headerfile, those functions are __stdcall, but they
are exported from the dll undecorated (without @nn).

- if i delete __stdcall from the header, my program crashes as soon as
  it calls ibdev (stack corruption i suppose)

- if i leave the .h-file as is, i get unresolved symbols ibdev@24,
  ibwrt@16 etc.

- if i create myself an import-library, using a decorated .def-file,
  it still crashes (does it link to the correct functions, anyway ?)
  using an undecorated import-lib still gives me unresolved symbols.

- giving --enable-stdcall-fixup to dlltool only seems to work when i
  *create* a dll and leave the .def-file undecorated, but i hadn't had
  any luck when using it when linking a foreign dll


some words about what i'm trying to do:
it's an extension to tcl (8.2.2) on windows that allows me to talk to
gpib-devices (unsing national's dll). i've already got it running
using LoadLibrary() and GetProcAddress(), but for the sake of
maintainability i would prefer to link against the dlls.


excerpt from tclgpib.c:
extern int __stdcall ibdev  (int ud, int pad, int sad, int tmo, int eot, int eos);
extern int __stdcall ibwrt  (int ud, void *buf, long cnt);
extern int __stdcall ibrd   (int ud, void *buf, long cnt);


excerpt from Makefile:
        dllwrap -o tclgpib.dll --def tclgpib.def -e "_DllMain@12" \
              tclgpib.o  dllinit.o \
              --enable-stdcall-fixup --target=mingw32 -mno-cygwin \
              //d/winnt/system32/gpib-32.dll //d/Programme/Tcl/bin/tcl82.dll

(dllinit.c is from mumit)

the tools are all installed from cygwin1.0-cd

hope somebody can make sense of all that ;-) 
if someone's got an idea for a patch for ld so i can use
--enable-stdcall-fixup when linking against a dll i would me *very*
happy :-))


TIA !
  -- oly
-- 
Oliver Nittka              | nittka@esem.com
ESEM Grünau GmbH & Co. KG  | http://www.esem.com
Dornierstraße 6            | phone: +49 7544 9583-25
88677 Markdorf / Germany   | fax:   +49 7544 9583-60


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]