lua-users home
lua-l archive

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

2008/11/25 pan shizhu <>:
> This is documented here:

The online PiL is outdated with respect to binary modules.

> On Tue, Nov 25, 2008 at 1:20 PM, Raúl Huertas <> wrote:
>> I'm starting with lua and i'm very excited learning the C API. Now I know
>> how to load my functions and use them in a lua program, but...
>> I0ve just installed wxWidget and it creates a .so called SO when in
>> lua, the standalone interpreter, finds 'require("wx")' laods that library
>> automatically. How this can be done? is there any special function to create
>> in that shared library? a lua_openlib(). How the module get loaded
>> automatically?

The different module searchers that are used by the 'require' function
are described in the online manual [1]

Basically all you need is to define the name of your module along with
its package name, for example where foo is the package and bar
is the module name. You then have to create a shared library which
exports a symbol named luaopen_foo_bar (if foo contains additionnal
dots, replace them with underscores). This symbol must be a
lua_CFunction [2]. The shared library should be named with a name
corresponding with one of the entries of package.cpath, for example