lua-users home
lua-l archive

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


I've run into a peculiar case while compiling and running my test suite for Lua and sol2 using Lua 5.2.4. In my tests, I build a lua_CFunction-containing DLL from source called "my_object". I also build Lua from source in various versions (everything from LuaJIT to Lua 5.3.4).

When I do require("my_object"), it works just fine on all platforms.... EXCEPT on Windows, when I compile Lua 5.2.4 as a static Library, and link that directly into the "my_object" and consuming executable. Code using require("my_object") fails with a runtime error, and the pushed error is a lightuserdata I cannot parse so I can't get any descriptive error out of Lua.

Compiling Lua 5.2.4 as a DLL and linking against the Lua DLL works just fine for the code.

Compiling Lua 5.3/5.1 statically or dynamically and linking against that for the DLL is also fine.

I don't know if anyone else has a Windows computer, but maybe I've just done something wrong? The example code is down here: https://github.com/ThePhD/sol2/tree/develop/examples/require_dll_example

my_object.cpp is built into a dynamic lib, require_from_dll.cpp is built into an executable, both link to Lua of whatever flavor I'm running the tests on.