lua-users home
lua-l archive

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

On Thursday, February 10, 2011 2:55 PM, Peter Odding wrote:
>	local apr = require 'apr.core'
>	-- .. and the script ends with ..
>	return apr
> The binary module is called "" ("core.dll" on Windows) and is 
> located in a subdirectory "apr" in one of the directories in Lua's 
> binary module search path. The loader function in the binary module [3] 
> is called "luaopen_apr_core".

Thanks, that got me headed in the right direction. I do have a problem with the libraries, though.

I now have a lib/aes/ file that contains
 luaopen_aes_core(lua_State *L)

That function calls luaL_register to load my wrapper functions (I cribbed your code).

  /* Create the table of global functions. */
  lua_createtable(L, 0, count(functions));
  luaL_register(L, NULL, functions);
  return 1;

After fixing up LUA_CPATH, the register function works but I'm getting an error from lua:

  error loading module 'aes.core' from file 'lib/aes/':
  lib/aes/ undefined symbol: lua_pushstring

I stripped the function down to two functions (luaopen_aes_core and my_version) and have only calls to lua_pushstring, lua_createtable and luaL_register in it. Whichever one is referenced first throws an error, basically the same error as above.

I have a C driver that sets up my environment, calls luaL_newstate(), luaL_openlibs(), then calls lua_pushstring a couple of times to set up a environment table. Then it calls luaL_loadbuffer() and lua_pcall() to run the scripts.

The main program links in liblua.a and I've confirmed that lua_pushstring is in there. If I don't run the script that uses requires to load the library, everything works nicely.

I'm not sure what else to look at for this.