Originally Posted by
Cybermonkey
I am still struggling with MacOSX but I still didn't manage to compile a simple Lua.pas example.
It's not as complicated as you make it out to be.
Assuming you already downloaded Lua.framework and put it in /Library/Frameworks , you just need to modify a part around line 45 in Lua.pas (as by default it does not look for the Mac library).
Original code:
Code:
const
{$IFDEF UNIX}
LUA_NAME = 'liblua5.1.so';
LUA_LIB_NAME = 'liblua5.1.so';
{$ELSE}
LUA_NAME = 'lua5.1.dll';
LUA_LIB_NAME = 'lua5.1.dll';
{$ENDIF}
New code:
Code:
const
{$IFDEF UNIX}
{$IFDEF DARWIN}
LUA_NAME = 'Lua';
LUA_LIB_NAME = 'Lua';
{$linkframework Lua}
{$ELSE}
LUA_NAME = 'liblua5.1.so';
LUA_LIB_NAME = 'liblua5.1.so';
{$ENDIF}
{$ELSE}
LUA_NAME = 'lua5.1.dll';
LUA_LIB_NAME = 'lua5.1.dll';
{$ENDIF}
Some additional notes about this:
- If you need Delphi XE2 compatibility, DARWIN is not defined with Delphi XE2. You need something like {$IFDEF FPC} {$IFDEF DARWIN} {$DEFINE MACOS} {$ENDIF} {$ENDIF} and change the {$IFDEF DARWIN} in Lua.pas to {$IFDEF MACOS}
- In older code fragments, you may find {$IFDEF DARWIN} ... {$ENDIF} code to link against a dylib. This is not necessary as Darwin as an OS is not distributed separately any more, just as part of Mac OS.
- {$linkframework Lua} links against the Lua framework from code and is the same as calling fpc -Mdelphi clscript.pas -k-framework -kLua from the command-line
- Lua.framework needs to put in the app bundle when distributing the application.
Bookmarks