tags:

views:

56

answers:

2

There is only one public library for binding Lua to Ada I have found (http://coreland.ath.cx/code/lua-ada), but how can it be used on a Windows platform? What do I need to use in my ada-project to get lua.ads.adb libraries defined in project-files working properly?

I tried to put lua sources in my ada-project directory befory compiling but that does nothing - GNAT raises an error like undefined reference to <c++ function>.

.

+2  A: 

Windows doesn't seem to be on Lua-Ada's list of supported platforms. Still, the bindings ought to be somewhat portable to other Gnat platforms. You would need to get hold of a Windows Lua library (most likely a DLL) and graft the two together somehow though.

It's doable - I did something similar with Clips once. However, anyone doing this is going to need to be (or become) quite conversant with the C/C++ linker, Mingwin's support for Windows libraries (typically through DLLs), and how Ada interfaces to C linkages work.

T.E.D.
Only by testing and testing once more I found how to bind safely Lua. First of all is to unpack lua-ext.c from Ada-Lua package and all Lua-sources to main Ada-project directory. Then renaming lua.c to lual.c (or something equal) to eliminate error with same object-file name ('lua.ads->lua.o | lua.c->lua.o'). The last one is to turn on C-compiler in GNAT. It could be done via "Project - Edit project properties - Languages". That's all I made to have my lua-files work with Ada-program.
Archinamon
@Archinamon: Grats! Since I can see you are a bit new with StackOverflow, allow me to make a suggestion: If you can write this up in an answer, then you could "accept" that answer. I know it seems a bit cheesy to be answering your own question, but that way other people searching on the same issue will easily be able to find the soltion. Also the SO system (and anyone surfing through it) will know this question has been resolved.
T.E.D.
Thanks for suggestion, I'll follow it.
Archinamon
@Archinamon: Cool. Now click on the little check mark next to your answer to "accept" it.
T.E.D.
I can't - system said me to wait till tomorrow. I'd made it after posting answer if I could.
Archinamon
@Archinamon: Ahhh, gotcha. Sometimes I forget what the rules are for newbies.
T.E.D.
+1  A: 

Only by testing and testing once more I found how to bind safely Lua. First of all is to unpack lua-ext.c from Ada-Lua package and all Lua-sources to main Ada-project directory. Then renaming lua.c to lual.c (or something equal) to eliminate error with same object-file name ('lua.ads->lua.o | lua.c->lua.o'). The last one is to turn on C-compiler in GNAT. It could be done via "Project - Edit project properties - Languages".

That's all I made to have my lua-files work with Ada-program.

P.S. To turn on all available Lua-libraries in Ada-program should be called those two procedures:

Lua.Lib.Open_Base(Lua.State_t); -- this will append to _G all main functions
Lua.Lib.Open_Libs(Lua.State_t); -- this will append math, string, package, etc. libraries
Archinamon