gudzpoz / luajava

Lua for Java on Windows, Mac OS X, Linux, Android. 5.1, 5.2, 5.3, 5.4, LuaJ or LuaJIT.
https://gudzpoz.github.io/luajava/
Other
141 stars 17 forks source link

Has no support for luarocks native libraries? #94

Closed osp54 closed 1 year ago

osp54 commented 1 year ago

When I try to load this code:

local lfs = require("lfs")

It gives an error:

error loading module 'lfs' from file '/usr/local/lib/lua/5.1/lfs.so':
        /usr/local/lib/lua/5.1/lfs.so: undefined symbol: lua_gettop

But when I run it in a normal lua interpreter, it's fine:

luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON fold cse dce fwd dse narrow loop abc sink fuse
> require "lfs"
> ^C

Additional information: Dist: luajit Luajava version: v3.4.0

gudzpoz commented 1 year ago

Thanks for reporting! No, I don't think loading external native libraries is supported now (although implementing it should be quite straightforward).

On Linux (or POSIX systems), JVM loads external libraries with dlopen without the RTLD_GLOBAL flag, causing the undefined symbol error. To fix this, we will need to load the library with that flag at some point, which might require tweaking the jnigen library (the library we use for multi-platform JNI) a bit. (See https://stackoverflow.com/a/54698767/17780636 .) I will try to implement it if I find the time.

osp54 commented 1 year ago

Thanks for reporting! No, I don't think loading external native libraries is supported now (although implementing it should be quite straightforward).

On Linux (or POSIX systems), JVM loads external libraries with dlopen without the RTLD_GLOBAL flag, causing the undefined symbol error. To fix this, we will need to load the library with that flag at some point, which might require tweaking the jnigen library (the library we use for multi-platform JNI) a bit. (See https://stackoverflow.com/a/54698767/17780636 .) I will try to implement it if I find the time.

No time at all? :(

osp54 commented 1 year ago

Thanks you