When a predicate imported from another module (see section 3.3) is called during execution, the dynamic loader is invoked automatically if the module is not yet loaded into the system, The default action of the dynamic loader is to search for the byte code file of the module first in the system library directories (in the order lib, syslib, and then cmplib), and finally in the current working directory. If the module is found in one of these directories, then it will be loaded ( on a first-found basis). Otherwise, an error message will be displayed on the current output stream reporting that the module was not found.
In fact, XSB loads the compiler and most system modules this way. Because of dynamic loading, the time it takes to compile a file is slightly longer than usual the first time the compiler is invoked in a session.