views:

108

answers:

4

Can a compiled Lua file (32bit *.luac file) work on a 64 Bit system?

A: 

I lack the experience to back up my words, but I believe that as long as the 32-bit lua binary is used to run that compiled file, it should work. Or rather, a binary built with similar settings, given the fact Lua offers a fair few compiler options that would affect the output of .luac files and their internal structure.

In general, the rule is not to mix usage of lua executables with .luac files created by another lua executable, as the inner format is highly dependant on the way Lua binaries themselves are compiled.

So if you run it with the 32-bit Lua you created the .luac files with, the answer is yes. If you were to run it with a 64-bit Lua executable, it would be a pretty definite no.

Stigma
+3  A: 

To quote the luac man page:

The binary files created by luac are portable only among architectures with the same word size and byte order.

So the answer is no. (I've also tested this exact situation with a 32-bit and a 64-bit machine.) One thing you can do is ensure that your Lua interpreter is compiled for 32-bit (even on a 64-bit machine), and I believe Lua would accept it then.

Quartz
You beat me to it. I was looking for that source but somehow failed to find that particular page. Bad googlefu for me today. :)
Stigma
A: 

Thanks for the answers. So, my problem is to find a nice guy who's able to compile my Lua file with a few functions in it on a 64bit machine, so that I have a 64bit version and my already compiled 32bit version. So i will have 64bit and 32bit files. And this will work on both architectuers I guess(of course by loading only the 64bit file on a 64bit system and the 32bit file on a 32bit system)?

luac
Please don't use answers to ask additional questions. The recommended practice at SO is to edit the question to add new information, or to ask new questions in new questions. You can edit a link to the follow up question into the original, of course. You can also comment on any question you ask and all its answers even with no rep score at all.
RBerteig
A: 

You didn't say why you want to deliver compiled Lua files (source code can be smaller, and loads quite quickly). In any case, an alternative to raw source is squish.

Doug Currie