PDA

View Full Version : Is this the way to link multiple .obj files into Delphi?



paul_nicholls
22-05-2009, 07:19 AM
Hi all,
I have a question:

Is there a better/eaiser way of importing multiple .obj files?

Explanation:

For couple of years now I have been using the Lua scripting language
(www.lua.org (http://www.lua.org)) from within Delphi 5 by using the interface unit + supplied
DLL.

Now I want to see if I can embed it into Delphi by not using the DLL but
compiling the source code and linking it into a Delphi unit.

I have downloaded the Lua source code (5.1) from here
http://www.lua.org/ftp/lua-5.1.tar.gz

I then tried following the instructions found at Rudy's Delphi Corner
(http://rvelthuis.de/articles/articles-cobjs.html) for using BCC32 5.5 to
compile and link c code into Delphi.


BCC32 -c *.c

This generated a whole bunch of .obj files from the c code.

I then tried making a Delphi 5 'import' unit like so:


Unit lua_import;

Interface

{$L lapi.obj}
{$L lauxlib.obj}
{$L lbaselib.obj}
{$L lcode.obj}
{$L ldblib.obj}
{$L ldebug.obj}
{$L ldo.obj}
{$L ldump.obj}
{$L lfunc.obj}
{$L lgc.obj}
{$L linit.obj}
{$L liolib.obj}
{$L llex.obj}
{$L lmathlib.obj}
{$L lmem.obj}
{$L loadlib.obj}
{$L lobject.obj}
{$L lopcodes.obj}
{$L loslib.obj}
{$L lparser.obj}
{$L lstate.obj}
{$L lstring.obj}
{$L lstrlib.obj}
{$L ltable.obj}
{$L ltablib.obj}
{$L ltm.obj}
{$L lua.obj}
{$L luac.obj}
{$L lundump.obj}
{$L lvm.obj}
{$L lzio.obj}
{$L print.obj}

Implementation

End.

I compile the unit and it rightly so complains about missing routines like "_lua_error" for example.

So I added in one of the interfaces like so:


..
{$L print.obj}

Type
Plua_State = Pointer;

function _lua_error(L : Plua_State) : Integer; CDecl; External;

Implementation

End.

When I add in the function above it now doesn't complain about that missing routine :)

I don't know if I can actually call the routines yet, but I will try after I
add in all the missing ones :)

cheers,
Paul

paul_nicholls
28-05-2009, 02:36 AM
What? 35 reads and no replies?
Now I'm sad :D

Seriously, does anyone know if I am doing this the best way?

I can create a .lib file too, but that isn't usable by Delphi...

cheers,
Paul

jdarling
28-05-2009, 03:54 AM
Yeah, there is a better way. Join the effort that is on-going on supporting and building Lua in FPC/Delphi instead of re-inventing the wheel :).

Seriously, there is no good way to embed the Lua library directly into an application in Delphi or Lazarus. I've been working on a complete 5.1 binary compatible port of the Lua VM, but progress is very slow.

- Jeremy

paul_nicholls
28-05-2009, 10:43 AM
Yeah, there is a better way. Join the effort that is on-going on supporting and building Lua in FPC/Delphi instead of re-inventing the wheel :).

Seriously, there is no good way to embed the Lua library directly into an application in Delphi or Lazarus. I've been working on a complete 5.1 binary compatible port of the Lua VM, but progress is very slow.

- Jeremy


Perhaps if I have time, I could help you with the Lua conversion?

cheers,
Paul