Recent

Author Topic: LUA Scripting - Dynamic Loading  (Read 7922 times)

wagenheimer

  • New Member
  • *
  • Posts: 21
LUA Scripting - Dynamic Loading
« on: January 14, 2011, 01:17:01 am »
I'm trying to Dinamic Load LUA in MAC-OS.

liblua5.1.dylib

Code: [Select]
LuaHandle:= DynLibs.LoadLibrary(ALibName);

  if LuaHandle = NilHandle then
  begin
     Result := False;
     Exit;
  end;

LuaHandle is always returning NilHandle. FileExists(ALibName) returns true.

I use the same command to load Bass (libbass.dylib) and it works.

Anybody have any idea of what is wrong?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: LUA Scripting - Dynamic Loading
« Reply #1 on: January 14, 2011, 01:36:37 am »
Are you specifying the complete path to it? What is the path?

Thanks.

-Phil

wagenheimer

  • New Member
  • *
  • Posts: 21
Re: LUA Scripting - Dynamic Loading
« Reply #2 on: January 14, 2011, 01:50:58 am »
Yes I am. FileExists(ALibName) is returning True.

There is the Lua.Pas and the liblua5.1.dylib that I'm using.

http://wagenheimer.com/temp/liblua5.1.dylib
http://wagenheimer.com/temp/Lua.pas

I use this same Lua.Pas in Windows and it works.

Please, if you can take a look would be very grateful.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: LUA Scripting - Dynamic Loading
« Reply #3 on: January 14, 2011, 01:56:57 am »
No, I meant what's the path to the library?

Try doing ExpandFileName to make sure it's a full path and not a relative path.

From Lua.pas:

    ALibName:= ExtractFilePath( ParamStr(0) ) + DefaultLibName;

That's probably giving you a relative path on OS X.

Thanks.

-Phil

wagenheimer

  • New Member
  • *
  • Posts: 21
Re: LUA Scripting - Dynamic Loading
« Reply #4 on: January 14, 2011, 02:08:54 am »
Thanks for the reply,

Well... I have changed it to

Code: [Select]
ALibName:=  ExpandFileName(GetCurrentDir() + '/'+DefaultLibName);

The ALibName value is
'/Developer/Games/Phoenix/demos.freepascal/_Compiled/liblua5.1.dylib'

And the .dylib really exists in this path, but it still does not works.

What else should I verify?

I will make a project to you test it.

Thanks

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: LUA Scripting - Dynamic Loading
« Reply #5 on: January 14, 2011, 03:08:28 am »
Where did you obtain liblua5.1.dylib? Or did you build it yourself?

Make sure it's not dependent on other libraries that you don't have:

otool -L liblua5.1.dylib

And compatible with your machine (Intel or PowerPC):

file liblua5.1.dylib

Thanks.

-Phil

 

TinyPortal © 2005-2018