I'm trying to use Lua 5.1 with luasocket in Eclipse Luna installed at Ubuntu 16.04.
I've already installed Lua 5.1 and LuaSocket 3.0-rc1 and I can run this program from command line (lua main.lua):
print(_VERSION)
print("Path: "..package.path..'\nCPATH: '..package.cpath)
socket = require("socket")
print(socket._VERSION)
and the result is:
$ lua main.lua
Lua 5.1
Path: ./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua
CPATH: ./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
LuaSocket 3.0-rc1
But when I try to run the same program using eclipse with lua plugin installed, I get this:
Lua 5.1
Path: ;./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/media/meslin/16E65872E6585459/Users/meslin/Google Drive/workspace-desktop-ubuntu/Lua Alo Mundo/src/?.lua;/media/meslin/16E65872E6585459/Users/meslin/Google Drive/workspace-desktop-ubuntu/Lua Alo Mundo/src/?/init.lua;/media/meslin/16E65872E6585459/Users/meslin/Google Drive/workspace-desktop-ubuntu/Lua Alo Mundo/src/?.luac;/media/meslin/16E65872E6585459/Users/meslin/Google Drive/workspace-desktop-ubuntu/Lua Alo Mundo/src/?/init.luac;
CPATH: ./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
Exception in thread "main" com.naef.jnlua.LuaRuntimeException: error loading module 'socket.core' from file '/usr/local/lib/lua/5.1/socket/core.so':
/usr/local/lib/lua/5.1/socket/core.so: undefined symbol: lua_gettop
at com.naef.jnlua.LuaState.lua_pcall(Native Method)
at com.naef.jnlua.LuaState.call(LuaState.java:555)
at org.eclipse.ldt.support.lua51.internal.interpreter.JNLua51Launcher.run(JNLua51Launcher.java:128)
at org.eclipse.ldt.support.lua51.internal.interpreter.JNLua51Launcher.main(JNLua51Launcher.java:143)
Any ideas? Can you help me, please?
Thanks Alexandre
The same issue was discussed on the lua maillist some time ago, see if the recommendation there helps you:
By default, LDT ships with a built-in Lua VM (based on jnLua) so as anyone without even having to install Lua on its machine can start running Lua scripts real quick. I think that the way you've set the PATH and CPATH, the jnLua VM itself is not found anymore.
What you probably want is to configure a "local interpreter" for your local native VM. You can use [1] as a reference. Once you have the interpreter set up, you can launch the script against this interpreter instead of the embedded jnLua one by tweaking your launch configuration.