lua-users home
lua-l archive

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


The problem does only manifest with Visual Studio 2017. When I build using MinGW's GCC 7.1.0 (or 7.2.0 or 6.3.0 or any others) the code works just fine. I suspect this might have something to do with Lua 5.2.4's config and how it loads a DLL. I will probably have to build Lua 5.2.4 in Debug mode and then through the code as it is being required to see what breaks and get back to everyone here.

On Sun, Feb 11, 2018 at 11:47 AM, Russell Haley <russ.haley@gmail.com> wrote:
Sorry for the top post. Are you building with Visual Studio? If so, it sounds like one of your build configurations might be a little different than the others?  From the configuration manager you can select manage configurations and in the drop down there should be an option for all configurations.  I'd double check the project isn't building a DLL by accident. 

My VS experience so far: I've had to set all configurations and go through each properties screen of each project to ensure they all align. WinLua currently only supports 5.1 and 5.3 so I've never tested against 5.2, nor have I tested my static libraries properly. WinLua builds a static and a dynamic library in separate projects in the one solution.

For What It's Worth,

Russ
Sent from my BlackBerry 10 smartphone on the Virgin Mobile network.
From: ThePhD
Sent: Sunday, February 11, 2018 6:24 AM
To: Lua mailing list
Reply To: Lua mailing list
Subject: require("some_dll") with a statically linked Lua 5.2.4

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.