lua-users home
lua-l archive

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


Hi,
I am still struggeling with the problem loading a C library called
clib.so into Lua.

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



My clib.c looks like this:
--------------8<-----------------------
static int l_file_exists (lua_State *L)
{
    const char* arg1 = luaL_checkstring(L,1);
    struct stat f1;
    if (stat (arg1, &f1) == 0){
      lua_pushboolean(L,1);
    }else{
        lua_pushboolean(L,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;
}
-------------->8-----------------------

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 clib.so.



Right? Ok!



Then I try to open the library with the command:

--------------8<-----------------------
package.cpath = "/path/to/clib/?.so"

require("clib")
-------------->8-----------------------

But I always get the message:

--------------8<-----------------------
lua: error loading module 'clib' ('loadlib' not supported)
-------------->8-----------------------


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