lua-users home
lua-l archive

Re: Advice request to build C functions in a library for Lua5.1

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


Alternatively, change mylib.c from:
LUALIB_API int luaopen_mylib (lua_State *L){
 lua_newtable(L);
 luaL_register(L, NULL, mylib);
 return 1;
}
to:
LUALIB_API int luaopen_mylib (lua_State *L){
 luaL_register(L, "mylib", mylib);
 return 1;
}
and use the following script:
#!/usr/bin/env lua
package.cpath = "./?.so;" .. package.cpath
require("mylib")
print "\nHello World\n"
-- call a C function and send a number
local indicator = mylib.prin(1)
print("The result is ", indicator)

AltStyle によって変換されたページ (->オリジナル) /