[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Loading dynamic libraries on Windows
- From: Georg Lehner <jorge-lua@...>
- Date: Sun, 06 Nov 2011 16:45:35 +0100
Hello!
I just found another detail to add to the excelent discussion in:
http://lua-users.org/wiki/LoadLibrary
As reported earlier on the list I had problems with loading "mime.core" and
"socket.core", while loading them individually worked without problems.[1]
The explanation can prominently be found in the Microsoft documentation
[2] for
the Windows CE/Windows Mobile API:
"..Two different modules cannot have the same file name, even if the
extensions
are different. These effectively have the same module name. For
example, if
LoadLibrary is made on Sample.cpl, the operating system will not load
Sample.cpl, but instead will again load Sample.dll. .."
My current solution modifies "findfile()" in loadlib.c by giving it a third
parameter "namesep", which is used to replace dots (".") in module names
before
handing it over to the path template.
When searching plain Lua modules (LUA_PATH_DEFAULT), "namesep" is set to
"LUA_DIRSEP" just as usual. However When searching C modules
(LUA_CPATH_DEFAULT)
the preprocessor macro LUA_CNAMESEP (invented by me) is used as
"namesep". I set
this to the underscore character ("_") which gives me the clearly
distinct module
filenames mime_core.dll and socket_core.dll.
A similar approach is used by Microsoft for their .Net Compact Framework
(_ instead
of separate directories for .Net .dll's in the GAC).
This approach would also help with (while not resolve) some of the
issues discussed
on the LoadLibrary Wiki page.
Regards,
Jorge-León
[1] http://lua-users.org/lists/lua-l/2011-10/msg00216.html
[2] http://msdn.microsoft.com/en-us/library/ms886736.aspx