lua-users home
lua-l archive

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


Well that was relatively painless. :)

I added #define LUA_LIB to the top of each lua.c, changed main(...) to LUA_API mainL(...) in both lua.c versions. I compiled them into their respective DLLs and hacked the 51 version to ignore the extra "-51" argument (it was just easier...). In my application  I load one file or the other and just pass the args as is. I'm quite chuffed with the results[1]: 

C:\Users\russh\projects\desktopLua> .\bin\dtlua.exe -e "print('this is a test')"
Filename is?: C:\users\russh\projects\desktoplua\bin\lua54.dllThe LoadLibrary(L"mydllpro") dll handle is valid...
The function address is valid: 00007FF96A5B5790

this is a test
FreeLibrary() is OK.

C:\Users\russh\projects\desktopLua> .\bin\dtlua.exe -51 -e "print('this is a test')"
Hello from Tokyo: -51Filename is?: C:\users\russh\projects\desktoplua\bin\lua51.dllThe LoadLibrary(L"mydllpro") dll handle is valid...
The function address is valid: 00007FF96A5BB280

this is a test
FreeLibrary() is OK.

Thanks to Josh Jensen again. I used his JamPlus build system and just stole from the example that builds lua. I wrote the whole thing in Geany and used Powershell command line to build. Nice!

Thanks so much for your help V. It's really great being able to ping these ideas off you. 

Perhaps, Dirk, you can have my nip of bourbon and celebrate for the both of us? :)

Russ
[1] Hello from Tokyo is my attempt to recall "Tokyo Rose" from second world war Japanese radio broadcasts

On Thu, May 3, 2018 at 3:41 AM, Viacheslav Usov <via.usov@gmail.com> wrote:
On Thu, May 3, 2018 at 7:52 AM, Russell Haley <russ.haley@gmail.com> wrote:

> So do I rename ...\lua5.1\src\lua.c(h) to  ...\lua5.1\src\lua51.c(h) as well or is that unecessary? I assume I include ...\lua5.1\src\lua.(h) in ...\lua5.x\src\lua.c?

Easiest would be to have a full set of unmodified source files for 5.1 and 5.x in separate directories, say src51 and src5x, then either lua.c will reference lua.h (and everything else) from its own directory. And then tweak those files as described earlier.

> I will need to try to understand why it needs to be static (I'll look that up).

You could try making the pointers not static and see what happens. I'm pretty sure the difference will then be obvious :)

> Here is another question the could only be asked by someone ignorant to C nuances: As an alternative to the above, could I just rename each main() to mainL() and make them NOT static, compile the lua.c files into the lua5x.dll and then just call the appropriate mainL from a new lua.c that I write?

If modifying lua5x.dll is an option, certainly.

Cheers,
V.