开发者

Binding Lua to Ada in win32 (xp,vista,etc.)?

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>.

.


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜