Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Message-ID: <004f01c0da1d$09b9c450$d2823bd5@dima>
From: "Dmitry Timoshkov" <dmitry@baikal.ru>
To: <cygwin@cygwin.com>
Subject: Linking with "stdcall" library
Date: Fri, 11 May 2001 21:18:42 +0800
MIME-Version: 1.0
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

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

