Logtalk reference manual
Built-in predicate: logtalk_compile/2
Contents > Reference Manual > Built-in Predicates > logtalk_compile/2

## logtalk_compile/2

#### Description

    logtalk_compile(File, Options)
    logtalk_compile(Files, Options)

Compiles to disk a source file or a list of source files using a list of compiler options. The Logtalk source file name extension (by default, `.lgt`) can be omitted. Source file paths can be absolute, relative to the current directory, or use library notation. This predicate can also be used to compile Prolog source files as Logtalk source code. When no recognized Logtalk or Prolog extension is specified, the compiler tries first to append a Logtalk source file extension and then a Prolog source file extension. If that fails, the compiler tries to use the file name as-is. Compiler option are represented as flag(value). For a description of the available compiler flags, please consult the User Manual.

Note that only the errors related to problems in the predicate argument are listed below. This predicate fails when errors are found during compilation of a source file.

#### Template and modes

    logtalk_compile(@source_file_name, @list(compiler_option))
    logtalk_compile(@list(source_file_name), @list(compiler_option))

#### Errors

File is a variable:
  `instantiation_error`
Files is a variable or a list with an element which is a variable:
  `instantiation_error`
File, or an element File of the Files list, is neither a variable nor a source file name:
  `type_error(source_file_name, File)`
File, or an element File of the Files list, uses library notation but the library does not exist:
  `existence_error(library, Library)`
File or an element File of the Files list, does not exist:
  `existence_error(file, File)`
Options is a variable or a list with an element which is a variable:
  `instantiation_error`
Options is neither a Options nor a proper list:
  `type_error(list, Flags)`
An element Option of the Options list is not a valid compiler option:
  `type_error(compiler_option, Option)`
An element Option of the Options list defines a value for a read-only compiler flag:
  `permission_error(modify, flag, Flag)`
An element Option of the Options list defines an invalid value for a flag:
  `domain_error(flag_value, Flag+Value)`

#### Examples

    | ?- logtalk_compile_1(list, []).

    | ?- logtalk_compile_1(types(tree)).

    | ?- logtalk_compile_1([listp, list], [source_data(off), portability(silent)]).