Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com Subject: building a cygwin DLL to run on non-cygwin app Message-Id: <20020815235332.19EDF3DEB@cavall.jtang.org> Date: Thu, 15 Aug 2002 19:53:32 -0400 (EDT) From: tang AT jtang DOT org (J. Tang) I have scoured the web and the mailing lists to no avail. How do I build a DLL to dynamically run with a non-cygwin application? Background: A vendor has supplied a program that links to a DLL at runtime to do stuff. I wish to write a DLL that this program may use. Here is some psuedocode from my DLL: long foo () { /* do some bit manipulations */ } I can build this fine using the ld/dlltool/ld/dlltool/ld trick. This also works if I just use the -shared flag to ld. The vendor's program, which I'll just call 'V', happily accepts it. At runtime, V has a parameter that specifies the DLL (i.e., my DLL must be relocatable). Everything works as expected. Now, suppose that I want to add some debugging info to my DLL, like so: #include long foo () { printf ("Entering foo.\n"); /* do some stuff */ } Compiling with ld fails because of the unresolved symbol printf(). I can make this error go away by adding a '-lc' flag to the end of ld. The DLL now compiles and builds. When I now run it under V, I get the application error: The instruction at "0x77f6ce4c" referenced memory at "0x00000010". The memory could not be "written". This seems to imply that linking to libc alters the DLL fundamentally. I have tried the following: - Try compiling with -mno-cygwin. I find that I still need the '-lc' flag, and the application error still occurs. - Remove the printf() call by leave '-lc'. Although V works, I really do want the debugging data. - Try changing the entry point with '-e __cygwin_noncygwin_dll_entry AT 12'. Apparantly this tricked worked with an older release of cygwin, but not anymore. The closest reference I have found is Mumit Khan's comment "if you're loading these from non-Cygwin application, eg., from an MSVC application..." at http://www.xraylith.wisc.edu/~khan/software/gnu-win32/dllhelpers.html. I tried this (bullet #3 above) but it no longer works. This is all with the latest stable release of the cygwin tools. Hopefully somebody here has insight on how to do this deceptively easy task. -- Jason Tang / tang AT jtang DOT org / http://www.jtang.org/~tang -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/