Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

LUA52.DLL?

May
12,845
164
I enabled LUA support and tried this
Code:
g:\tc16> lua -i
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> require "winapi"
I got a message box from TCC
---------------------------
tcc.exe - System Error
---------------------------
The program can't start because lua52.dll is missing from your computer. Try reinstalling the program to fix this problem.
After dismissing the message box, I got this from LUA in the console.
error loading module 'winapi' from file 'G:\TC16\winapi.dll':
The specified module could not be found.

stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
 
So I downloaded a LUA52.DLL from sourceforge (lua.org only has 5.1). And I tried the same thing (lua -i ... require "winapi"). This time TCC crashed (no GPF file).
Code:
Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   tcc.exe
  Application Version:   16.0.37.0
  Application Timestamp:   52dc4694
  Fault Module Name:   StackHash_17f8
  Fault Module Version:   0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Code:   80000026
  Exception Offset:   00000000
  OS Version:   6.1.7601.2.1.0.256.48
  Locale ID:   1033
  Additional Information 1:   17f8
  Additional Information 2:   17f8d7c365e333667d9c35fdc8b76d2f
  Additional Information 3:   80b4
  Additional Information 4:   80b41c6439d1927fb8df7cbb88585ebd
 
You're inventing imaginary features again ...

And the crash is in the lua dll, not in TCC.
What feature is imaginary ... that TCC's LUA can load a module built for LUA 5.2? That should be a feature of LUA, not of TCC.
 
T
1) Where did you see that documented?

2) You're reporting a TCC bug (it's not), not a Lua bug (it is).
The help mentions LUA's "require" which is used to load modules. TCC's LUA tried to load the the specified module and failed. The module in question is linked to lua52.dll which exports pretty much what your lua.dll exports (but with undecorated names). That's all I know. Experienced LUA users might expect to be able to use external modules.
 
The help mentions LUA's "require" which is used to load modules. TCC's LUA tried to load the the specified module and failed.

The help mentions "-l _mod_"; it says nothing about "require".

The crash is due to the winapi module you're trying to load, which is hard-coded to only work with a Lua dll named "lua52.dll" (and which crashes when it doesn't find it).
 
The help mentions "-l _mod_"; it says nothing about "require".

The crash is due to the winapi module you're trying to load, which is hard-coded to only work with a Lua dll named "lua52.dll" (and which crashes when it doesn't find it).
And when it does find it, your lua.dll crashes. Do you know of any external modules that can be loaded by TCC's LUA? Perhaps the source to winapi is available ... it might not be too hard to get it to work with your DLL. Do you have a LIB to match your DLL?
 
And when it does find it, your lua.dll crashes. Do you know of any external modules that can be loaded by TCC's LUA? Perhaps the source to winapi is available ... it might not be too hard to get it to work with your DLL. Do you have a LIB to match your DLL?

What's crashing is winapi.dll, not lua.dll. Looking at winapi.dll, I can see that they built it with gcc, with different default options than msvc uses (so winapi can't find exported functions in lua, and vice versa). There aren't any "standard" lua dll's & libraries for Windows; everybody builds their own (incompatible) versions.

I've made a change for 16.00.38 so it will work with the gcc + lua 5.2 variation of winapi.dll (though probably not the mingw version).
 
Thanks. Indeed, my little experiment of last night works now.
Code:
v:\> unset zzz

v:\> lua -i
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> require "winapi"
> winapi.setenv("zzz","foobar")
>
^C
v:\> set zzz
foobar

Should the "-l _mod_" work when starting an interactive LUA session? The help shows a space between "-l" and "_mod_". The only thing I could get to start an interactive session was to omit the space. Then LUA did not complain until I tried to use the module.
Code:
v:\> lua -l _winapi_ -i
-l: cannot open _winapi_: No such file or directory

v:\> lua -l winapi -i
-l: cannot open winapi: No such file or directory

v:\> lua -l "winapi" -i
-l: cannot open winapi: No such file or directory

v:\> lua -l "_winapi_" -i
-l: cannot open _winapi_: No such file or directory

v:\> lua -l_winapi_ -i
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> winapi.setenv("zzz","football")
stdin:1: attempt to index global 'winapi' (a nil value)
stack traceback:
  stdin:1: in main chunk
  [C]: in ?
>
 
Oh ... FWIW ... The upgrade to build 38 did not overwrite the LUA52.DLL I put there last night (had to download and repair).
 
Hmmm! The help gives this example.
Code:
lua -e'a=1' -e 'print(a)' script.lua

will first set a to 1, then print the value of a (which is '=1='), and finally run the file script.lua with no arguments.

One "-e" has a space after it, one doesn't. What's up with '=1='? After 'a=1' the value of a should be just 1. Leaving out the script name, I can't get the example to work, with or without the spaces.
Code:
v:\> lua -e'a=1' -e'print(a)'
-e'a=1': (command line):1: unexpected symbol near ''print(a)''

v:\> lua -e "a=1" -e "print(a)"
-e: cannot open a=1: No such file or directory

The same if (as in the help's example) I add a script name.
Code:
v:\> lua -e'a=1' -e'print(a)' script.lua
-e'a=1': (command line):1: unexpected symbol near ''print(a)''

v:\> lua -e 'a=1' -e 'print(a)' script.lua
-e: cannot open 'a=1': No such file or directory

Another example from the help doesn't seem to work (that is, set LUA's prompt).
Code:
v:\> lua -e"_PROMPT='myprompt> '" -i
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
>
And that example, without "-i" still leaves me in interactive mode.
Code:
v:\> lua -e"_PROMPT='myprompt> '"
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
>

LUA's version info prints with or without "-v"

If "-i" is before the script name, LUA doesn't enter interactive mode after running the script. It the "-i" is after the script name, LUA enters interactive mode but doesn't (appear to) run the script.
Code:
v:\> type script.lua
print('foo')

v:\> lua -i script.lua
foo

v:\> lua script.lua -i
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
>
 
Doesn't have anything to do with TCC; the Lua parser (in lua52.dll) is doing all of the argument parsing. Ask the Lua developers.
Regardless, don't you think the help should give examples that work. be consistent (space or no space after "-e",), and simply be clearer ('=1='', and all those underscores)? There's also the example "lua -la b.lua t1 t2" with no mention of what the "-la" does. I can only gather that "a" is the name of a required module (but that doesn't seem to work when the name of an existing external module is used).
 
Regardless, don't you think the help should give examples that work. be consistent (space or no space after "-e",), and simply be clearer ('=1='', and all those underscores)? There's also the example "lua -la b.lua t1 t2" with no mention of what the "-la" does. I can only gather that "a" is the name of a required module (but that doesn't seem to work when the name of an existing external module is used).

The syntax and examples are from lua.org. I don't think it would be a good idea for me to second-guess them and rewrite their examples.
 
The syntax and examples are from lua.org. I don't think it would be a good idea for me to second-guess them and rewrite their examples.
Hmmm! They don't work. Maybe if you passed "Lua" as the first arg to Lua().

Are you building LUA52.DLL? I made a working version of it from a VC10 project (DEF file and all). [It has no DllMain (yet works!) ... how does that happen?] If you want the project I'll send it to you.

You can change the "-v" behavior (version info printing even without "-v") by adding a "break;" in the "i" case in collectargs() in lua.c as I did below. They even noted the fall-through for interactive instances.
Code:
  case 'i':
  noextrachars(argv[i]);
  args[has_i] = 1;  /* go through */
     break;     //  <============================ I added this one
  case 'v':
  noextrachars(argv[i]);
  args[has_v] = 1;
  break;
 
Just a nitpick, but the name of the language is Lua, not LUA. It's a word (Portugese for "moon"), not an acronym.

Nitpicking because I can't use TC16 at all right now because of the triple-character-input bug. On my machine it looks like:

llluuuaaa
 
Nitpicking because I can't use TC16 at all right now because of the triple-character-input bug. On my machine it looks like:

llluuuaaa

What operating system?

Is the "splitter windows" option (Options / Take Command, "Tabs", at the bottom of the section labelled "Windows") checked?
 
I'm pretty sure now that the first arg to Lua() should be "Lua". Lua uses it's argv[0] as it's "progname" elsewhere, and below, it thinks it's progname is "FireFox".

Code:
v:\> lua FireFox -x
FireFox: unrecognized option '-x'
usage: FireFox [options] [script [args]]
Available options are:
  -e stat  execute string 'stat'
<snip>
 
Just a nitpick, but the name of the language is Lua, not LUA. It's a word (Portugese for "moon"), not an acronym.

Nitpicking because I can't use TC16 at all right now because of the triple-character-input bug. On my machine it looks like:

llluuuaaa

Does this happen with one tab window open, or only if you have several open?
 

Similar threads

Back
Top