- Recompiled Lua with the Digital Mars C compiler.
(Here're some add-on files to simplify this.)
Any ANSI C compiler + lib tool should do, which can produce OMF libs. (I only had Lcc handy, and it did COFF, which DMC doesn't like.) You may also buy the Digital Mars Extended Utility Package and use COFF2OMF.
- Simply started wrapping the Lua API, like this:
extern (C) { alias void* lua_State; lua_State lua_open(); void lua_close(lua_State); int lua_baselibopen(lua_State); int lua_iolibopen(lua_State); int lua_gettop(lua_State); void lua_settop(lua_State, int); int lua_dostring(lua_State, char*); int lua_dofile(lua_State, char*); } - The D main() looked like this (almost exactly as in C):
void main(char[][] args) { int res; lua_State l = lua_open(); lua_baselibopen(l); lua_iolibopen(l); res = lua_dofile(l, "chunk.lua"); // '\0' appended by D to // such string literals if (res != 0) { printf("couldn't read file\n"); } lua_close(l); } - And "chunk.lua" simply was:
print "Hello from Lua!"
- Now, just compile and link all the stuff together:
dmd test.d liblua.lib liblualib.lib
- That's it, works like a dream...
Hello from Lua!