lua-users home
lua-l archive

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

I am still struggeling with the problem loading a C library called into Lua.

I read the 5.1-Beta manual four times but I can't get it right

My clib.c looks like this:
static int l_file_exists (lua_State *L)
    const char* arg1 = luaL_checkstring(L,1);
    struct stat f1;
    if (stat (arg1, &f1) == 0){
    return 1;

static const struct luaL_reg clib[] =
    {"newer", l_newer},
    {NULL, NULL}

int luaopen_clib (lua_State *L)
  luaL_openlib(L, "__library", clib, 0);
  return 1;

So I am having the loaopen_ loader function implemented. But I have done
this in Lua-5.0 too.

The I compiler my library for Mac OS X and get an

Right? Ok!

Then I try to open the library with the command:

package.cpath = "/path/to/clib/?.so"


But I always get the message:

lua: error loading module 'clib' ('loadlib' not supported)

Sorry that I have again bothering you with this problem, but I really
got stucked and I am some kind of desperate.

By the way: It would be very helpful to have a real working example
concering C Libraries.

Thank you all so much!

Kim Herig

Kim Herzig
Software Engineering Chair
Prof. Dr. Andreas Zeller
Software Engineering Chair (Prof. Zeller)
Saarland University, Dept. of Informatics