[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Chicken-users] RE: Win32/cygwin dynamic loading

From: Jonah Beckford
Subject: RE: [Chicken-users] RE: Win32/cygwin dynamic loading
Date: Mon, 17 Feb 2003 12:44:11 -0500

Yes, cygwin/mingw32 libtool handles most things, except 
1. dllimports of DLL data (ie. extern'd variables).  Needs an explicit
__declspec(dllimport) attribute on the 'extern'.
2. It also doesn't allow backlinking (there are other operating systems
that don't allow this as well).  That means you cannot have a DLL have
an external reference to some function or data in the main application;
one area it comes up in is that C_toplevel (defined in the application)
is always needed by a CHICKEN module/DLL.
3. Some platforms (ex. AIX, and Win32 to some extent) require a
self-contained shared library.  That means that srfi-37 in a shared
libsrfi cannot depend on regex in a shared libstuffed, and lolevel in a
shared libstuffed cannot depend on srfi-4 in a shared libsrfi.  (note:
those are the only non-self-contained examples in the current CHICKEN).
Actually, Win32 will allow a non-self-contained shared library, but
cygwin/mingw libtool cannot be easily made to accept the circular
dependency of libsrfi <-> libstuffed.

What I did ...

Good and easy solution for 1:  Just put __declspec(dllimport) on the
variables in chicken.h if BUILD_CHICKEN_DLL was not defined.

Not-so-good solution for 2: Require an extra parameter to
CHICKEN_initialize/invoke/run that is a pointer to the C_toplevel.  Then
this pointer to C_toplevel can be passed to the unit when it is loaded
from the DLL.  Not-so-good because it is an backwards-incompatible

Horrible solution for 3: Just move regex.o and srfi-4.o into libchicken.

So I got it working on cygwin and mingw32 (just for proof-of-concept)
but the method can be improved substantially to not rely on libtool
(Visual C++ should still be a viable compiler to produce DLLs, as a
Visual C++ application with a mingw DLL cannot be debugged easily) and
to make the dynamic loading be available on all platforms that support
any kind of shared library (even if it is quite primitive).  

I will present the solution after I have the new proof-of-concept
working ...


-----Original Message-----
From: Felix Winkelmann [mailto:address@hidden 
Sent: February 17, 2003 4:11 AM
To: Jonah Beckford
Cc: address@hidden
Subject: Re: [Chicken-users] RE: Win32/cygwin dynamic loading

Jonah Beckford wrote:
> Ignore that ... I figured out how to do it, on cygwin at least.  I 
> will see about submitting it sometime after I get native Win32 working

> as well.

Hey, I would be interested to know about this. Isn't libtool supposed to
handle these things? Anyway, thanks for your help!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]