lua-users home
lua-l archive

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


On Tue, Jan 12, 2010 at 1:17 PM, David Burgess <dabsoft@gmail.com> wrote:
> So your issue is with package.loadlib rather than require() ?
I do not think so.

Assume that we are distributing some executable which uses LuaCURL,
and loads it via require"curl". One could distribute all the required
files alongside each other:
my-app/my-lua-app.exe
my-app/curl.dll (the Lua glue around the CURL library)
my-app/libcurl.dll (the actual CURL library, placed in a separate DLL
due to being a different license)

Say that one wants to move Lua extension DLLs to their own directory.
It would be nice to add the extensions directory to package.cpath, and
then do something like:
my-app/my-lua-app.exe
my-app/extensions/curl.dll
my-app/extensions/libcurl.dll

However this will not currently work. require"curl" will find
my-app/extensions/curl.dll, but curl.dll depends upon libcurl.dll, and
the Windows DLL loader has no knowledge of package.cpath, so it will
try (and fail) to load my-app/libcurl.dll (as the default DLL search
order looks in the directory of the EXE, rather than the directory of
the dependee DLL being loaded). For things to work, either
LOAD_WITH_ALTERED_SEARCH_PATH needs to be used, or dependant DLLs
would need to be placed in my-app/ rather than my-app/extensions/.