lua-users home
lua-l archive

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


With regards to the need for a DLL under Windows this is essentially just
the way it is.  You need some mechanism to ensure that the App AND the
extensions are linking to the same version of Lua.  Otherwise differences in
implementation could cause "Bad Things" when you go passing a Lua state back
and forth between them.  Even if you provide some method for assuring that
the same version of Lua is used (say linking to a predetermined static
library) you will have problems due to the C run time state information
(typically expressed as an exception condition when one instance of the C
run time fails to free data allocated by the other instance because the data
did not come from the expected heap instance).

In point of fact the memory allocation/deallocation issue is the only issue
that I know of.  Theoretically you could work around this by modifying Lua
to accept/use alloc/free function callbacks (as is the plan for 5.1).

In the end the "brute force" method "where the app exports the needed
functions through a callback structure" is really the best method for
ensuring version compatibility.  This ensures that all extensions are using
the same version (and same single loaded instance) of Lua.  Of course you
need some system for naming the versions so that the extension can decide
for itself if it can properly function with that version.


-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Brian Hook
Sent: Monday, April 12, 2004 10:32 PM
To: Lua list
Subject: loadlib was Re: 3D Math libs for Lua


On Mon, 12 Apr 2004 23:11:54 -0400, Thatcher Ulrich wrote:
> The loadlib() function built into Lua 5.0 does the job nicely; this
> is what luacheia uses under the hood now.

Cool, I somehow missed that when stumbling around the Wiki.  I'm
confused by the following though:

http://lua-users.org/wiki/CreatingBinaryExtensionModules

What's the status with that?  There's conflicting data in there, but
it seems to imply that binary loadable modules will require the app to
use Lua in a DLL on Windows.

There are some ways of fixing this (a la Quake2/3 where the app
exports the needed functions through a callback structure -- brute
force, but surprisingly effective), but I'm not sure what the current
state is.

Brian