I'm trying to wrap torch in python, and I get this really odd error "libpaths.so: undefined symbol: lua_gettop)" when I try to "require 'nn'", or "require 'paths'". I've been fighting with this for hours, so wondering if anyone has seen something similar, seen a solution? Trying to simplify the problem as much as possible, I created a C, or C++ (tried both :-P) shared object that does:
void go(void) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
lua_getglobal(L, "require");
lua_pushstring(L, "nn");
lua_call(L, 1, 1);
lua_setglobal(L, "nn");
lua_close(L);
}
... nothing complex really.
If I build this as an so, and call this from a C (or C++) executable, it works ok. If I build this as an .so, then call it from python, it gives the undefined symbol error. I'm linking the .so brutally with liblua5.1.so.0, so gettop should be present. I also tried including the entire Lua sourcecode, ie lapi.c and so on, in the shared library, still hvae the same issue. I'm wondering if it's something to do with linker options passed to the python wrapper, or maybe something in the python enviornment? The python wrapper that calls the shared object is linked as:
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/pytest.o -Lbuild -L/usr/lib/x86_64-linux-gnu -Wl,-R. -Wl,-Rbuild -Wl,-R/usr/lib/x86_64-linux-gnu -ltestlib -llua5.1 -o build/lib.linux-x86_64-2.7/pytest.so
If anyone has any ideas what is going on, would be much appreciated :-) Dont need a full solution, just if any hints as to what might be breaking, even the smallest amount of information, might be enough to somehow 'break through' this issue.
Hugh