Subject: DLL problems
From: "Li Ning" <[email-masked]>
To: <[email-masked]>
Date: Wed, 23 May 2001 17:26:26 +0800

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