Module dependencies

Lua modules

You don't need to give ljc all the lua modules that your main source file depends on. Ljc will parse your source files for the required modules and compile them too. Note that only requires statements with modules specified by a Lua string are parsed. Dynamic requires are not detected. The search algorithm is the same as the standard Lua specification (package.path).

In the following example, ljc will compile "main.lua" without errors :

-- main.lua

local module = "pdf"

At main.exe execution, a runtime error will be thrown complaining that the module "pdf" could not be found. To avoid this kind of runtime errors, it's up to you to give ljc the files needed at runtime with the following command in this case :

ljc.exe main.lua pdf.lua

Binary modules

As for Lua modules, binary modules (dynamic libraries compiled for Lua) are searched during compilation time if required by your main source file (using package.cpath). You cannot specify a binary module in the command line : you have to deploy the required dynamic libraries with your executable.

During compilation, ljc will warn you about your executable dependencies (including binary modules) and will check that the binary module is targeted towards the same Lua version as your executable.

If you use the LuaJIT virtual machine, don't forget to deploy the dynamic libraries accordingly to the FFI definitions.

Hint : Be careful with some Lua packages that ask you to modify your LUA_PATH or LUA_CPATH environment variables. These packages may use a non-standard method to ‘require’ Lua files, and may cause compilation errors.

Hint : Binary modules are copied to the output path (by default, the current folder)