lua-users home
lua-l archive

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


(sorry, if this is posted twice, wrote first to the old list address)

I have some problems when compiling modules and main programs into one object

Example

==== main.lua ====
local sub_mod=require"sub.mod"
print("Version",sub_mod._VERSION)
print("Function",sub_mod.Function())
==================

==== sub/mod.lua ====
module("sub.mod")
local M={}
M._VERSION="0.1"
function M.Function()
    return "Result"
end
return M
=================

This works fine, when running main

>lua main.lua
Version    0.1
Function    Result

Now I want to compile that to /one/ deliverable object:

luac -o Release/prog.luac sub/mod.lua main.lua

But testing the prog fails

>cd Release && lua prog.luac
Version    nil
lua: main.lua:7: attempt to call field 'Function' (a nil value)
stack traceback:
    main.lua:7: in main chunk
    (luac): in main chunk
    [C]: ?

Please tell me, how to manage this cleanly'n'correct

Regards, Jørgen