[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Tool to assist static linking.
- From: Tim Channon <tc@...>
- Date: Wed, 13 Aug 2008 02:05:19 +0100
Static linking Lua.
I have written a Lua licensed tool in ANSI C which takes a small
configuration text and automatically creates a pair of C files, .h and
.c which act as a binding between mixed mode Lua libraries and a core C
Including the header and a call to a function in your Lua interpreter C
file immediately after loading the base Lua libraries is all that is
needed, plus an optional call to a second function to load further Lua
source at a later time during initialisation. This can include a final
Lua source which does not return until program termination and that is
turnkey standalone single executable Lua app.
The test candidate was Luasockets and is a trivial use.
One way of using this is compiling any library C sources into a static
library and then link when compiling Lua proper, perhaps with a main app.
In essence it is a very simple interpreter and code generator.
The Lua sources compiled into the .c can be text or binary.
A simple example source file looks like this
call int luaopen_lfs (lua_State *L);
call int luaopen_socket_core (lua_State *L);
call MIME_API int luaopen_mime_core(lua_State *L);
# a comment
script socket.lua socket
script ltn12.lua ltn12
script tp.lua tp
script mime.lua mime
script url.lua url
script ftp.lua ftp
script http.lua http
script smtp.lua smtp
include #include "luasocket.h"
include #include "mime.h"
run url.lua url
run web.lua web
It requires the Lua source files available for reading and writing into
the generated C file.
Resulting files not shown here.
I could do with advice and input. It knows nothing about OS and so it is
best if all data is in a single directory. (relative paths can be given)
My knowledge of Lua is minimal but I pre-date the invention of the
microprocessor, been around. Historically an embedded system, assembler
and Forth guru more tending to Wirth languages. Been watching Lua for
years as a likely rising star. As of 5.1 came of age.
The fun part of writing was...
Writing printf which writes printf to printf.
I could put a URL to the sources here but I don't want blacklisting.