0

I have some problems using LuaInterface on Mono, Ubuntu. I have followed instructions here, but when I try to compile and run program in Mono, I got following error:

Program:

using System;
using LuaInterface;

public class TestLua {

public static void Main(string[] args) {
    Lua lua= new Lua();  // will open all the standard Lua libraries
}

}

Error:

Unhandled Exception: System.DllNotFoundException: luanet.so
  at (wrapper managed-to-native) LuaInterface.LuaDLL:lua_pushstdcallcfunction     (intptr,LuaInterface.LuaCSFunction)
  at LuaInterface.ObjectTranslator.createBaseClassMetatable (IntPtr luaState) [0x00000] in <filename unknown>:0 
  at LuaInterface.ObjectTranslator..ctor (LuaInterface.Lua interpreter, IntPtr luaState) [0x00000] in <filename unknown>:0 
  at LuaInterface.Lua..ctor () [0x00000] in <filename unknown>:0 
  at TestLua.Main (System.String[] args) [0x00000] in /home/zbynek/Plocha/csharp/Game/Lua/LuaProject/Program.cs:7 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: luanet.so
  at (wrapper managed-to-native) LuaInterface.LuaDLL:lua_pushstdcallcfunction (intptr,LuaInterface.LuaCSFunction)
  at LuaInterface.ObjectTranslator.createBaseClassMetatable (IntPtr luaState) [0x00000] in <filename unknown>:0 
  at LuaInterface.ObjectTranslator..ctor (LuaInterface.Lua interpreter, IntPtr luaState) [0x00000] in <filename unknown>:0 
  at LuaInterface.Lua..ctor () [0x00000] in <filename unknown>:0 
  at TestLua.Main (System.String[] args) [0x00000] in /home/zbynek/Plocha/csharp/Game/Lua/LuaProject/Program.cs:7 

Which is a strange error. I could understand, if .dll file could not be find, but .so?

Does anyone has an idea, how to fix this?

Thanks Zbynek

Zbynek
  • 5,673
  • 6
  • 30
  • 52
  • 1
    https://github.com/stevedonovan/MonoLuaInterface/issues Open an issue and you should be able to receive answers from the developers. – Lex Li Dec 19 '13 at 08:27

1 Answers1

0

Related to this:

It must be compiled with a reference to LuaInterface.dll, and both luanet.so and liblua5.1.so must be accessible on the library path.

LuaInterface is found so you have the reference, but most likely none of the items in LIB_PATH is the folder that contains luanet.so.

You could try printing LD_LIB_PATH in your .cs (comment out the using LuaInterface) to check that it really is set:

using System;

...

String libPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
Console.WriteLine("LD_LIBRARY_PATH:   " + libPath);

Ensure the permissions on the .so is correct (for example if they are root and you are normal user you probably won't be able to load).

Ensure that LuaInterface.dll found is the one in $LUAI and not some other.

Also look at Mono shared library under linux location.

Community
  • 1
  • 1
Oliver
  • 27,510
  • 9
  • 72
  • 103
  • I have file luai, which has following lines: `LUAI=/home/zbynek/MonoLuaInterface/bin`, `export LD_LIBRARY_PATH=$LUAI`, and luanet.so, as well as LuaInterface.dll, is in `/home/zbynek/MonoLuaInterface/bin` – Zbynek Dec 19 '13 at 07:25
  • I tried `string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);` which in fact gave me `bin/Debug` of my current project. I copied luanet.so to that directory, but the error remains the same – Zbynek Dec 19 '13 at 13:25
  • You need to use System.Environment. I updated my answer to show that. Also, have you checked the other items in answer (permissions, which LuaInterface.dll, and other SO post). – Oliver Dec 19 '13 at 16:33