PDA

View Full Version : Can someone try to build the Lua demos in Linux?



jdarling
11-10-2006, 07:49 PM
I still don't have my linxu box back up and running (don't ask). But I have uploaded a modified copy of the Lua 5.1 libs and demos (as well as an OO demo and co-routines demos that may or may not work). It would be great if someone could try and build them in FPC for Linux and see if they work (as well as report back the progress).

Download URL: http://www.eonclash.com/LUA/lua5.1.zip

Thanks,

grudzio
11-10-2006, 10:36 PM
Since I don't have Lasarus installed on linux, I have compiled only non LCL samples. I had only two minor issues. First: the default fpc compilation mode does not recognise 'result' variable, so I suggest adding

{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}

to the lua.pas.
Second: there are few warnings about Destroy method overriding the inherited one. It concerns TLuaThread, TLuaThreadList, and TLuaClass.

Unfortunatelly I am not able to run the demos because of the linking problem. I have downloaded lualib5.1.so but I've got linking errors:


"liblua5.1.so: undefined reference to 'dlerror'",
"liblua5.1.so: undefined reference to 'dlclose'"
"liblua5.1.so: undefined reference to 'dlopen'"
"liblua5.1.so: undefined reference to 'dlsym'".

So how about changing the lua.pas to dynamic linking? :wink:

That's all from me.

grudzio
11-10-2006, 11:00 PM
All right, I fixed my problem :D . Adding 'dl' to uses clause in lua.pas and moving liblua5.1.so to \usr\lib directory did the trick.

I have tested luaootest, cotest and cotest2. The first two run fine, the third gave me Lua Exeption error. (No number guessing game :cry: )

jdarling
11-10-2006, 11:23 PM
Unfortunately you can't use dynamic linking with Lua and FPC. I don't know why, all I know is that it blows chunks if you try to.

Granted I haven't tried dynamic linking with 5.1

Since it looks like the changes to lua.pas and luautils.pas are minimal, I'll add them in and send it over to the FPCTut guys to have it all brought in.

The 3rd demo crashing doesn't surprise me :). It does that on windows as well (still trying to figure out why, but I think I got it when I fixed the oo demo).

Thanks for giving a try,

JernejL
19-10-2006, 10:00 AM
this has nothing to do with linux build, but luadelphi, it seems you used some charset that delphi 4 cannot "swallow" and i have difficulties displaying the forms even after converting them to D4 binary format.

edit: also, you use only LF for line returns in pas files, this makes D4 compiler go crazy about lines longer than 1024 characters.

technomage
19-10-2006, 12:00 PM
If you get this problem you can either grab my Format Linux files

which is here (http://www.cerebral-bicycle.co.uk/viewdoc.asp?doc=306)

or open the offending source file in wordpad and save it. :D

jdarling
19-10-2006, 01:12 PM
Hmm... Interesting point Delfi, I never thought about D4 and below. Since I use Lazarus and FPC with Scite for everything now :). I'll have to put a link to the tool that technomage pointed out for those that need D4 support.

technomage
19-10-2006, 02:28 PM
Delphi 5 has the same problem with LF / CRLF. It's a handle thing to have when developing for cross platform.

JernejL
19-10-2006, 03:01 PM
well, i pretty much got the headers to work with D4, the only real problem were two undeclared sysutils funcs which i copied from D7 RTL, also D4 has no varargs (unless you count quake 2 delphi pas asm sprintf implementation as one ;) )

so basicly i got it to work by doing this:

simply uncommenting varargs here:
function lua_pushfstring(L: Plua_State; const Fmt: PChar): PChar;// varargs;
cdecl external 'lua.dll';

and here:
function luaL_error(L: Plua_State; const Fmt: PChar): Integer; //varargs;
cdecl external 'lua.dll';

basicly, thats the only thing i can do in D4, since i can't make use of those funcs because d4 has no varargs support in compiler.

and i copied these two funcs from D7 RT into luautils.pas:

function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
function AnsiDequotedStr(const S: string; AQuote: Char): string;

and now it pretty much works fine in D4, i just had to do some manual converting of DFM files into d4 format, for example, it does not like the widechars being declared for a widestring, like #2342#2131, so i had to clear all those, and then convert them to D4 binary format.

marcov
27-10-2006, 06:04 PM
[quote="jdarling"]Unfortunately you can't use dynamic ]

Try to use cmem, dynlibs, cthreads

as first units in your main program.

Better use dynlibs than unit dl. It's typing is better defined.