views:

257

answers:

2

Since my game, which I'd really like to be Mono-usable, does not seem to run under Linux because LuaInterface is being a jerk (see the the relevant SO thread for more on that), I've decided to do what's suggested there. I wrote my own Lua511.LuaDLL class to reflect the one used by LuaInterface, replacing every single public function with its respective DllImport from lua51:

//For example, like this:
[DllImport("lua51")]
public static extern IntPtr luaL_newstate();

With the edited LuaInterface.dll (which now hosts its own Lua511.LuaDLL) and a pure, native Win32 lua51.dll in my game's startup folder, I somehow get a DllNotFoundException when LuaInterface tries initialize:

public Lua()
{
   luaState = LuaDLL.luaL_newstate(); //right there, right then.
   ...

Ofcourse, with the DLL right there it shouldn't do that, right? Strangely, putting back the messed-up .Net version of lua51.dll gives an EntryPointNotFoundException instead. The mind boggles.

So what's up with that?

Relevant source code: Lua511.cs, dropped it in the LuaInterface project, then removed the reference so it'd be replaced.

Edit: Screw this, I'm gonna look for alternatives. Or roll my own. Or just stop caring about Linux compatibility.

A: 

AFAIK mono uses .so extension for native libraries under Linux by default.

Try to rename your lua51.dll to lua51.so or change dllname in DllImport attribute. Or use dllmap.

elder_george
Eeeeeh no. I'm running this under Windows, actually. And the DllImport does not specify an extension.
Kawa
Oh, sorry, I've misunderstood.I've examined lua51.dll from LuaInterface with Dependency Walker and found that it exports *no* functions. Then I've rebuilt lua51 from sources. It started to load and then failed with EntryPointNotFoundException for function (both on .NET and Mono). This is normal since there's no such function - this is a macro in lua.h defined on top of lua_createtable. The same is for many others 'functions' in lua.h. So, I think you should replace dll imports for them with calls to real functions and you've had a chance to make LuaInterface working.
elder_george
I've edited your file lua511.cs to run simple scripts. see here http://pastie.org/659584. Hope this will help
elder_george
+2  A: 

Hey Kawa!

You referenced my question. I took the other way to solve the problem and started to develop a new Lua .NET interface. I called it Lua4Net.

You can find the sources on Google hosting. And here the unit tests.

Currently implemented features: Execute code with exception handling and provide the return values; register global functions with parameter handling.

Features that will follow: Get/set global variables; debugging support, ...

You can find the used native windows DLL here (it is the renamed VC++ 9.0 DLL from here).

AND: Today I ran my first Linux/Mono tests, and all my unit tests worked!!!

ulrichb
Very impressive. I'll have to check this out later today...
Kawa