Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <001d01c0e36a$711676b0$7800a8c0@liningw2ks> Reply-To: "Li Ning" From: "Li Ning" To: 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 AT 12 It complains: /usr/lib/libcygwin.a(libcmain.o)(.text+0x6a):libcmain.c: undefined reference to `WinMain AT 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