This is the mail archive of the cygwin@cygwin.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]

Linking with "stdcall" library


Hello all.

Sorry if it was already answered before. But reading faq.txt didn't help.

This time I'm experimenting with creating library which does export
functions with stdcall naming convention. I *really* need to create
and use them, so it's not an option to use cdecl instead.

Here is the description what I do:

I created test-dll.def file:
-- start of test-dll.def --
EXPORTS
    MyCloseHandle
-- end of test-dll.def --

then I created import library libtest-dll.a using dlltool:
dlltool --add-stdcall-alias --input-def test-dll.def --output-lib libtest-dll.a

then I created test-gcc.c source which uses function exported by libtest-dll:

-- start of test-gcc.c --
#define __stdcall __attribute__((__stdcall__))

extern void __stdcall MyCloseHandle(int handle);

int main(void)
{
    MyCloseHandle(-1);
    return 0;
}
-- end of test-gcc.c --

then I compile test-gcc.c and try to link it with import library libtest-dll.a:

gcc -c -O2 -Wall -o test-gcc.o test-gcc.c
gcc -o test-gcc2 -Wl,--enable-stdcall-fixup test-gcc.o -L. -ltest-dll

test-gcc.o(.text+0x11):test-gcc.c: undefined reference to `MyCloseHandle@4'
collect2: ld returned 1 exit status

It seems that --enable-stdcall-fixup doesn't help. Why?
Replacing MyCloseHandle in test-dll.def by MyCloseHandle@4 makes linker happy.
By it is not the right fix.

Any suggestions?
Thanks in advance.
--
Dmitry.


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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