MovingBlocks / JNLua

Fork of JNI-based Lua scripting language integration for the JVM
MIT License
18 stars 22 forks source link

dynamic libraries not enabled; check your Lua installation #4

Closed zxj12530 closed 6 years ago

zxj12530 commented 6 years ago

i test on macosx but got this error

Exception in thread "main" org.terasology.jnlua.LuaRuntimeException: error loading module 'cjson' from file '/usr/local/lib/lua/5.3/cjson.so':
  dynamic libraries not enabled; check your Lua installation
  at org.terasology.jnlua.LuaState53.lua_pcall(Native Method)
  at org.terasology.jnlua.LuaState.call(LuaState.java:733)
  at org.terasology.jnlua.test.LuaScriptTest.callLua(LuaScriptTest.java:23)
  at org.terasology.jnlua.test.LuaScriptTest.main(LuaScriptTest.java:14)
asiekierka commented 6 years ago

The default-compiled natives should not allow loading external libraries from the Lua side, as that would be a security concern in the context we're using JNLua in. You may have to add additional compile flags.

zxj12530 commented 6 years ago

Can you give some advice for the “additional compile flags”?

Are you saying that the additional compile flags are Lua_Type, or what?

We commonly use macosx and linux

We must to use the dynamic library

zxj12530 commented 6 years ago

We use lua5.1 is normal, why 5.3 will have security concern?

asiekierka commented 6 years ago

@zxj12530 We are developing JNLua with a video game in mind, loading user-provided code on servers. Loading dynamic libraries would be a huge security liability.

Try replacing the LUA_TYPE in the script with "macosx" on Mac and "linux" on Linux instances.

asiekierka commented 6 years ago

We'll take care of this after other, more pressing parts of the project are done: see https://github.com/MovingBlocks/JNLua/issues/6

zxj12530 commented 6 years ago

Thank you, I have modified LUA_TYPE to macosx and linux, but still report the error.

asiekierka commented 6 years ago

Try passing -DLUA_USE_DLOPEN directly, then. Maybe that will do.

zxj12530 commented 6 years ago

change Makefile.mac like this ?

CFLAGS?=-O2 -DLUA_USE_MACOSX -DLUA_USE_DLOPEN

asiekierka commented 6 years ago

Yes. This might help.

zxj12530 commented 6 years ago

Ok, I will try it later, then give you feedback.

zxj12530 commented 6 years ago

I followed the instructions you said, I did the following:

(1) Modify Makefile.mac          CFLAGS?=-O2 -DLUA_USE_MACOSX -DLUA_USE_DLOPEN

(2) modify build-natives-eris_mac.sh         LUA_TYPE="posix" is changed to LUA_TYPE="macosx"

(3) Generate libjnlua-5.3-mac-amd64.dylib and put it under /Library/Java/Extensions (4)./gradlew build generates JNLua-0.1.0-SNAPSHOT.jar (5) My project uses the Lua5.3 version, and the cjson library compiled with 5.3

When I execute the call, I still get an error.

Exception in thread "main" org.terasology.jnlua.LuaRuntimeException: error loading module 'cjson' from file '/usr/local/lib/lua/5.3/cjson.so':
Dynamic libraries not enabled; check your Lua installation
asiekierka commented 6 years ago

You forgot to modify the CFLAGS in the shell script itself. Makefile.mac controls the building logic of the Java glue and does not control Lua itself.

Modfiy MY_LUA_CFLAGS in the shell script. Sorry if this is unclear right now, development of the fork of JNLua has been focused on other things (such as improving the quality of the native library itself) and not everything is well-documented yet.

zxj12530 commented 6 years ago

Hello, there is still a problem, I see "This branch of Eris currently comes with Lua 5.3.0"

We tested with lua5.3.5

Will this version of the difference affect?

i will try to Modfiy MY_LUA_CFLAGS in the shell script

asiekierka commented 6 years ago

Will this version of the difference affect?

The branch actually comes with Lua 5.3.5. A bit of text has not been updated, I suppose.

zxj12530 commented 6 years ago

ok,thank you!