lua-users home
lua-l archive

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

Well I have the error now and it is a bit of an issue. First some set up

The C wrapper

#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
int main(int argc, char **argv) {
  const char *error;
  lua_State *L = luaL_newstate();
  if (luaL_dofile(L, "here/boot.lua") == LUA_OK) {
    lua_pop(L, lua_gettop(L));
  } else {
    error = lua_tostring(L, -1);
  return 0;

is compiled with 

cc -o here.Linux.x86_64 boot.c -Wall -Werror -fPIC -ansi -static -O3 -DLUA_C89_NUMBERS -I/usr/include/lua5.3/ -llua5.3 -lm -ldl

Which issues only 1 warning

/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/liblua5.3.a(loadlib.o): In function `lookforfunc':
(.text+0x596): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

There is only 1 version of lua on this computer, 5.3, and if I run the script from the shell

$ lua5.3 here/boot.lua

It works just fine, if I run the compiled version

$ ./here.Linux.x86_64
here/boot.lua:31: ./here/lib/socket/ undefined symbol: lua_gettop

But the symbol is there

$ nm ./here/lib/socket/ | grep lua_gettop
                 U lua_gettop

Now my googling seems to say that luasocket is probably not being compiled in a way that exports the symbols correctly but the posts I've found are focused on lua <-> rust / python bridges and older versions of lua, 5.1

However I am installing luasocket as a dependency of luasec with luarocks so I am unaware of the correct incantation to get the magic to happen

The same C and lua scripts work just fine on on my mac (slightly different cc options because you can't do a real static compile on macos)

Any pointers for me here or should I be skipping luarocks and compiling luasocket from source (which I would prefer not to)?