[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Coding 5.1-style packages to allow static linking of C code..
- From: duck <duck@...>
- Date: Sun, 9 Jan 2005 04:36:56 +0000
Just took a bit of time to look at compat-5.1.lua, and at the
the thread from September 2004 where the package stuff came from.
Now, consider a hybrid C/Lua pacakge in which you require() Lua code which
itself require()s a C library (e.g. luasocket). Do I understand correctly
that if you statically link the C library, then you must register its
initialisation function in the table package.preload at startup time, so
that require() will behave correctly?
OTOH, a package written entirely in C can be statically linked,
initialised at startup and added to package.loaded *or* handled via
package.preload, as above.
If I've got this correct, my next question is this: is there a proposed
standard way (or a standard luaL_helper() function) to take care of the
Indeed, is there a propsed standard way for hybrid C/Lua packages to have
their Lua code "statically linked" and tidily called from the library
initialisation code in the standard Lua interpreter?
(At the moment, statically-linked C libs are handled simply by adding
their init functions to the EXTRA_LIBS list. It would be neat if there
were a similarly elegant and standard way to "statickise" libraries like
luasocket -- and, indeed, compat-5.1 :-) -- to make the building of an
all-in-one Lua binary easy.)