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 Message-ID: <8D861ADC5B8FD211B4100008C71EA7DA04F70BDA@kjsdemucshrexc1.eu.pm.com> From: "Demmer, Thomas" To: "'cygwin AT cygwin DOT com'" Subject: Using cygwin DLLs in no-cygwin applications Date: Thu, 16 May 2002 09:36:35 +0200 MIME-Version: 1.0 Content-Type: text/plain Hi all, a while ago I tried to include some legacy FORTRAN and C code into a DELPHI project of mine. Building a DLL (according to Mummit Khan's description) seemed the way to go. Under Cygwin, this ended up admiring SIGSEGVs all over the place. Under MinGW, however, everything worked out fine (Searching this list would have told me right away that including cygwin1.dll from a non-cygwin app does not work). So far for my stupidity. Anyway, more or less out of curiosity I tried the following: procedure TForm1.FormCreate(Sender: TObject); var bzopen : Function(const name:PChar; const Mode:PChar):Pointer;cdecl; bzclose: Function(s:Pointer):Integer;cdecl; bzwrite: Function(s:Pointer;data:Pointer;len:Integer):Integer;cdecl; hCygz : LongInt; s : Pointer; begin hCygz := LoadLibrary('cygz.dll'); if hCygz<>0 then begin @bzopen :=GetProcAddress(hCygz,'gzopen'); @bzclose:=GetProcAddress(hCygz,'gzclose'); @bzwrite:=GetProcAddress(hCygz,'gzwrite'); s := bzopen('test.z','wb9'); if s<>nil then begin bzputs(s,PChar('Hello World'); bzclose(s); end; end; end; To my utmost surprise, this piece of code works. After loading cygz I can even call some functions from cygwin1 after getting their address with GetModuleHandle/GetProcAddress (malloc/free/getcwd). The question now is, which magic initialization does cygz that my self built DLLs lack? (BTW, I have just written a glue layer for cygregex.dll that works just after the same scheme...Why?) Ciao Tom Thomas Demmer Kraft Foods R&D Munich Phone: +49 89 62738-6302 Fax: +49 89 62738-86302 Thought of the Day: An age is called Dark not because the light fails to shine, but because people refuse to see it. -- James Michener, "Space" -- 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/