This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Using cygwin DLLs in no-cygwin applications


Hi Thomas,

It's been quite a while since I've last seen Pascal,
and fine if it works, but do you want gzip or bzip2?
Your code uses gzip, prefixing variables bz doesn't matter!
OK, not cygwin specific, but you might have overlooked...


Bye, Heribert (heribert_dahms@icon-scm.com)

> -----Original Message-----
> From:	Demmer, Thomas [SMTP:TDemmer@krafteurope.com]
> Sent:	Thursday, May 16, 2002 09:37
> To:	'cygwin@cygwin.com'
> Subject:	Using cygwin DLLs in no-cygwin applications
> 
> 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
> 

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]