The LuaTeX documentation says the following:

Loading dynamic Lua libraries will fail if there are two Lua libraries loaded at the same time (which will typically happen on win32, because there is one Lua 5.3 inside LuaTEX, and another will likely be linked to the dll file of the module itself).

The question simply is: How I can avoid this problem? I have compiled my own Lua outside of LuaTeX and then compiled other Lua modules against this Lua DLL with the accompanying .lib. Now I want to use this library also in LuaTeX, but I don't find ANY information on how to solve this problem.

Any help is appreciated :)


I was not specific enough. My problem is exactly the one in the quote. I am on Windows and I get the multiple lua vms detected error, because I linked my modules DLL to the .lib of my self-compiled Lua and I'm trying to use this same DLL with LuaTeX. I already found out about --shell-escape and it finds my DLL at the normal LUA_PATH. But I don't know how to enable my DLL to be used with any Lua 5.3 there is.


In TeX Live, kpse searches DLL by values of CLUAINPUTS, in the case that kpse is used. Default is

(1) current directory
(2) $BINDIR/$progname/lua//
(3) $BINDIR/$engine/lua//
(4) $BINDIR/lua//

If kpse is not used, DLL is searched, for example, in $BINDIR. luatex uses kpse, and texlua does not use kpse by default, of course texlua also uses kpse if initialized appropriately. In recent luatex, the option


is necessary to load a DLL.

  • Please see my edit. I am exactly at the point where the DLL, it found, fails to load, because of multiple vms detected :/
    – SkryptX
    May 15 '20 at 14:35
  • In the case of TeX Live w32 (32bit), define the names of lua-5.3.5 libraries as lua53.dll and lua53.lib. Link your module with the import library lua53.lib. Don't use your lua53.dll, and use your module only. May 15 '20 at 21:45
  • I'm using MikTeX not TeX Live and I don't really understand your advice. I tried renaming the lua53.dll in my PATH directory. Then it throws a generic error, that it failed to load a sublibrary inside the DLL. The library I want to load is luasec with its ssl.dll and ssl.https.
    – SkryptX
    May 15 '20 at 22:18
  • Don't forget to build lua-5.3.5 library as a DLL: Compile options may be: -DLUA_COMPAT_5_2=1 -DLUA_BUILD_AS_DLL=1 -DLUA_COMPAT_MODULE=1 -DLUA_COMPAT_LOADSTRING=1 -DLUAI_HASHLIMIT=6 May 15 '20 at 22:18
  • I did use LUA_BUILD_AS_DLL, but not the others.
    – SkryptX
    May 15 '20 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.