lua-users home
lua-l archive

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


Keith Pimmel wrote:
> Casually looking through the source code in loadlib.c, I didn't really see 
> a case that covers cygwin (i.e., Windows binaries, but it doesn't seem to 
> define _WIN32, which is what defines LUA_DL_DLL in luaconf.h).

Like David Burgess said, LUA_DL_DLOPEN is probably the right define
to add to the Makefile for cygwin. But to be honest, I've not used
cygwin for quite a while ... I think it's overly complicated.

> I guess what I'm asking, after introducing all that noise above, is has 
> anyone ever done dynamic library loading in cygwin, and what did they do 
> to do it, as I'm not having a ton of success.

My suggestion is to use MINGW:

This provides you with an open source build environment (compiler,
linker, header files, make utilities), but links against standard
MS DLLs. The resulting binaries can be run everywhere (without
dragging in multi-megabyte cygwin libraries). It's very easy to use
Windows specific calls and _WIN32 is defined, too (so LUA_DL_DLL is
automatically defined).

You can run MINGW native on Windows or cross-compile for Windows
from a Linux or *BSD host.

Look for customized packages for your distribution first before
building this yourself. E.g. for Gentoo you want to emerge all
of dev-util/xmingw-*.

> I looked at Mike Pall's page on the Wiki, and while I linked against a 
> static lua51.a library instead of a lua51.dll, I think I did everything I 
> was supposed to. (

Linking dynamic modules to the static library containing the Lua core
is not a good idea (no matter which build environment you use).

Essentially you are adding a copy (!) of the whole Lua core
(or at least large parts of it) to every module. Apart from being
a waste of space this may lead to very difficult to diagnose
problems. The different instances of the core code don't know
anything about each other and may not necessarily be in sync.

I've added a few more explanations to the Wiki:
(look at the end of the page)