[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Proxy DLL for Lua 5.1; can't get it to work with statically linked liblua
- From: Paul K <paulclinger@...>
- Date: Mon, 25 Nov 2013 12:12:03 -0800
> "The host library file can be either a DLL or an EXE, the requirement is that it must have all the required functions exported."
> Is this requirement fulfilled with regards to your statically built interpreter?
As it turned out the answer was "no", as I didn't see anything
exported from the executable. The process of getting the symbols
exported is a bit more involved than I thought, but in the end I made
it work with something like this:
dlltool --export-all --output-def lua.def lapi.o ldebug.o ldo.o
lstate.o lauxlib.o lbaselib.o ldblib.o linit.o liolib.o lmathlib.o
loadlib.o loslib.o lstrlib.o ltablib.o
dlltool --dllname lua.exe --def lua.def --output-lib liblua.a
dlltool --dllname lua.exe --output-exp lua.exp --def lua.def
gcc -g -o lua.exe -Wl,--base-file,lua.base lua.exp lua.o liblua.a
dlltool --dllname lua.exe --base-file lua.base --output-exp lua.exp
gcc -g -o lua.exe lua.exp *.o
This generates a statically compiled lua.exe that exports all the
symbols defined in the files on the first line (LUA_API and
LUALIB_API); this could be replaced with "pexports lua51.dll
>lua.def", but the result is almost the same.
The generated executable works with ProxyDllFour, although I couldn't
get it to work with ProxyDllTwo: when I generate the dll against that
executable, it is 143K and it crashes with c000001e error in lua51.dll
(proxy). I do get a warning when I compile the DLL:
gcc -shared -s -nostdlib temp_obj.o lua.def -L. -ltemp_dll -olua51.dll
ld.exe: warning: cannot find entry symbol _DllMainCRTStartup@12;
defaulting to 66d81000
Now I just need to do it for Lua 5.2 and LuaJIT... Is there a simpler
way to achieve the same result?
On Mon, Nov 25, 2013 at 5:52 AM, Shmuel Zeigerman <email@example.com> wrote:
> On 25/11/2013 09:33, Paul K wrote:
>> I tried to use ProxyDll2 (http://lua-users.org/wiki/LuaProxyDllTwo),
>> both Shmuel's and David's solution, but I guess I did something wrong
>> as the process hangs after "require 'winapi'" (winapi is the library
>> I'm "practicing" on). Everything works with a "normal" interpreter
>> that is linked against lua51.dll.
> "The host library file can be either a DLL or an EXE, the requirement is
> that it must have all the required functions exported."
> Is this requirement fulfilled with regards to your statically built