Compiling Lua for D

Jesse Phillips jessekphillips+D at gmail.com
Wed Feb 15 21:06:11 PST 2012


On Wednesday, 15 February 2012 at 19:49:13 UTC, Mars wrote:
> I assume I could compile those, and include them in my other 
> lib... but why is that? Shouldn't the Lua lib, and the 
> importing of those files be enough? I couldn't really wrap my 
> head around that yet, if I import something, that's not in my 
> project, aren't those files included? Is that why I also have 
> to make a lib for it? What exactly happens when importing?

Importing just tells the compiler that you wish to use the 
symbols for the imported module. This is different from C`s 
include as that is just a text replacement.

Importing does not make those modules compiled into you obj file. 
Each module is given there own object file and generally this is 
how you`ll build each C file. These obj files can then be 
packaged in a lib.

There is however a difference between the compile and link stage. 
During compilation the important part is to know what is 
contained in an obj/lib. This is why we import/include, the 
signature of the external code tells the compiler the calling 
convention being used. The linker on the other hand does not care 
about the imports and is only putting the used code together 
(linking).

So when building an application against Lua it must provide the 
header files such that the compiler knows what will be found in 
the library/external code.

BTW, I totally recommend LuaD when interacting with lua.


More information about the Digitalmars-d-learn mailing list