Problems linking stdcall functions from DLL

Raoul Gough
Thu Sep 4 15:09:00 GMT 2003

I'm trying to link to a third party DLL that has functions with
stdcall calling convention, but *without* stdcall name decoration
(i.e. no trailing @N). Reading the ld documentation (for 2.14.90), it
looks like this should "just work", and produce warnings unless
--enable-stdcall-fixup is provided. In fact, it always produces hard
"undefined reference" errors. I've distilled this to a minimal

---8<--- begin test script ---8<---------

cat >stdcall_export.c <<EOF
__attribute__((dllexport,stdcall)) int foo () { return 5; }

cat >stdcall_import.c <<EOF
__attribute__((dllimport,stdcall)) int foo ();
int main () { return foo(); }

/bin/gcc -shared -o stdcall_export.dll stdcall_export.c -Wl,--kill-at
/bin/gcc -o stdcall_import stdcall_import.c stdcall_export.dll

---8<--- end test script ---8<------------

$ ./
 undefined reference to `__imp__foo@0'
collect2: ld returned 1 exit status

The given code works fine if the --kill-at is omitted. So why doesn't
it resolve the reference to (dllimport) foo@0 with the corresponding
plain (dllexport) foo? Have I misunderstood how automatic stdcall
fixup works, or is this an ld bug?

ld version is 2.14.90 20030901, but problem was the same in 2.13.90

Raoul Gough.
(setq dabbrev-case-fold-search nil)

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list