lua-users home
lua-l archive

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


Chris Gurtler wrote:
If I use the following line
require("hello")
Then I get an error : loop or previous error loading module

But if I use the following line it works ok.
lib=package.loadlib('hello.dll','Hello_Init')

Do I need to change my dll to make sure that require works?

From http://www.lua.org/manual/5.1/manual.html#pdf-require:

When loading a C library, require first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside this library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its prefix up to (and including) the first hyphen is removed. For instance, if the module name is a.v1-b.c, the function name will be luaopen_b_c.

So my first guess is that you'll need to rename or alias Hello_Init to luaopen_hello.

 - Peter Odding