lua-users home
lua-l archive

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

Nick Gammon wrote:
I have spent a couple of days now trying to get my program (a MUD
game client) to compile and run with Lua 5.2.

It's taken a while, partly because it took around 2 days to even get
it to compile, what with the deprecated functions, removal of
LUA_GLOBALSINDEX, luaL_typerror, lua_equal, lua_unref, lua_getref and
a few others.

I struggled with that for a while too - then I just set LUA_COMPAT_ALL
in a command line define and the problem went away. There's a lot of
existing libraries that would break otherwise.

Well, expectation or not, the fact is that there are a lot of Lua
scripts out there, and major work is likely to be on the horizon for

But the big issue is the crashes. Why are there crashes? Because of
the DLLs (I am talking Windows here, and yes I know it would be good
to avoid Windows if possible).

I have modules that use luasocket, for example. Now the DLLs that
ship with that are linked against lua5.1.dll - and since it can find
a lua5.1.dll in the path, it loads it. So I now have the main program
pulling in lua52.dll and some modules loading in lua5.1.dll - and
sooner or later the whole thing crashes, because of the malloc/free
problems with clashing DLLs.

Time to rebuild and relink against 5.2 then.

So how do we avoid all this? Short of completely upgrading from Lua
5.1 to Lua 5.2 and removing all traces of Lua 5.1 from my system
(hardly a practical choice), we need a way of making the Lua 5.2
modules pull in Lua 5.2-compiled DLLs (like luacom, luasocket, and so
on). But I'm not sure how this is achieved easily. Right now, for
example, luasocket itself pulls in two DLLs, rather confusingly named
core.dll and core.dll (in different directories).

Is the solution to rigorously keep DLLs into their own directory
paths - even those with the same names (eg. core.dll and core.dll)?
Or is it to impose a naming convention on then (eg.

I have a build system for the Lua core under Linux that builds
for Windows using mingw32 and friends.

With a bit of fiddling in the luaconf.h file customisation
section, I can force Lua to look in certain places for DLLs.

The output of my build system looks like this:

usr/local/bin/lua52.exe and lua52.dll


I can put the "usr" root anywhere in the Windows file system
and as long as I run programs from that spot, it always finds
the DLLs

Or, I can put it under C:/ and customize luaconf.h and run
Lua from anywhere on the Windows system.

Maybe I'm just lucky, but 5.2 offers a lot of really nice additional
features for embedded guys like me, especially the new emergency GC.