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: <001d01c0e36a$711676b0$7800a8c0@liningw2ks>
Reply-To: "Li Ning" <lining@mail.bitmate.com>
From: "Li Ning" <lining@mail.bitmate.com>
To: <cygwin@cygwin.com>
Subject: DLL problems
Date: Wed, 23 May 2001 17:26:26 +0800
Organization: BitMate
MIME-Version: 1.0
Content-Type: text/plain;
	charset="gb2312"
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
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id FAA18040

Dear friends,

I have been struggled hard to make dll running but failed.
Please help.

My purpose is to trun a cygwin compiled C program into a 
dll, so that I can call it from Microsoft VC or VB.

My environment is: Windows 2K server with cygwin 1.3.2-1 
installed.

Following "Cygwin User's Guide" Chapter 4 "Building and 
Using DLLs", I just tried a small program first:

mydll.c
---------------
int foo (int) __attribute__ ((__dllexport__));
int foo (int i){return i+1;}
---------------

mydll.def
---------------
EXPORTS
foo
---------------

Then I did the following:

gcc -c mydll.c

gcc -s -Wl,--base-file,mydll.base -o mydll.dll mydll.o -Wl,-e,_mydll_init@12 

It complains:

/usr/lib/libcygwin.a(libcmain.o)(.text+0x6a):libcmain.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status

What's rwong?

I have tried other ways to test dlls, I have added cygwin1.dll into the VC
link options to compile a small program, VC complains:

Linking...
cygwin1.dll : fatal error LNK1136: invalid or corrupt file
Error executing link.exe.

Does that mean that there is no way to let VC access cygwin programs?

I would be very appreciate if any one can provide me a complete set of
working demo program to show me the whole process to build a DLL for
Win32 / VC. 

Thanks

Ning Li





