lua-users home
lua-l archive

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


i was looking for a way to create lua stand alone
with luasocket as a single binary. my search
has returned nil so far.

any pointers or links would be most helpful.

There are two independent issues to that.

One is how to get require"foo" to find a package "foo" that was linked
statically to the executable,  instead of trying to load it from the
disk. The standard way to do this is via the Lua package proposal, by
means of the package.preload table.

Placing a function in package.preload["foo"] will instruct require"foo"
to use that function as the loader instead of trying to find it
automatically by other means.

The other issue is how to get the many Lua modules in LuaSocket to get
linked statically to your executable. For that, you should use luac and
bin2c, both available from the Lua distribution.

Once you are familiar with these two issues, it's just a matter of placing all the loaders into package.preload during the initialization of your binary.