This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Using cygwin DLLs in no-cygwin applications
- From: "Demmer, Thomas" <TDemmer at krafteurope dot com>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Thu, 16 May 2002 09:36:35 +0200
- 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
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/