[Top][All Lists]

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

Re: [Chicken-users] Units as shared libraries (SWING, dynamic, does not

From: felix winkelmann
Subject: Re: [Chicken-users] Units as shared libraries (SWING, dynamic, does not work)
Date: Mon, 13 Dec 2004 07:46:01 +0100

On Sat, 11 Dec 2004 16:10:22 +0100, Thomas Chust <address@hidden> wrote:
> >
> > Is there a particular reason for this restriction? How can I work around
> > this issue?
> I don't know, why this restriction exists, although I think the reason
> is that it's just easier to hardcode a dynamic function load call for
> "C_toplevel" instead of "C_<unit-name>_toplevel" especially because the
> unit name would not necessarily be correlated with the shared object's
> name...

Yes, that describes the problem pretty well.

> I work around this problem by including something like
> (cond-expand
>   ((or chicken-compile-shared shared)
>    )
>   (else
>    (declare (unit my-unit-name))))
> at top of the unit's source code. By the way, I would suggest to add a
> feature to csc: The compiler should declare the features static and/or
> chicken-compile-static as available when compiling code with the -static
> option beause then you could equally easily write something like

Ok, will do.

> If you have dynamically generated scheme code including unit
> declarations, you could, if it was absolutely necessary not to modify
> it, rewrap the code by writing another scheme file which would import
> the unit in question and reexport all its symbols. This file you would
> compile and link together with the original compiled wrapper code into a
> shared object. But I admit that this is a clumsy solution (and also an
> untested one ;)

Actually `load-library' should work here, provided the code has
been compiled like a normal shared library

% cat yo.scm
(declare (unit yo))
(print "yo!")
% csc yo.scm -vc
/usr/local/bin/chicken yo.scm -output-file yo.c -quiet
gcc yo.c -o yo.o -g -c -DC_NO_PIC_NO_DLL
rm yo.c
% gcc yo.o `chicken-config --libs --cflags` -shared -o
% csi
; loading /usr/local/lib/chicken/ ...
; loading library posix ...
; loading library srfi-1 ...
#;1> (load-library 'yo "./")
; loading library yo ...


reply via email to

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