Configure & Build Cantera

These directions are for the development version of Cantera. For the current release, see these instructions.

Determine configuration options

  • Run scons help --options to see a list of all of the configuration options for Cantera, or see all of the options on the Configuration Options page.

  • Configuration options are specified as additional arguments to the scons command. For example:

    scons command option_name=value
    

    where scons is the program that manages the build steps, and command is most commonly one of

    • build

    • test

    • clean

    Other commands are explained in the Build Commands section.

  • SCons saves configuration options specified on the command line in the file cantera.conf in the root directory of the source tree, so generally it is not necessary to respecify configuration options when rebuilding Cantera. To unset a previously set configuration option, either remove the corresponding line from cantera.conf or use the syntax:

    scons command option_name=
    
  • Sometimes, changes in your environment can cause SCons's configuration tests (for example, checking for libraries or compiler capabilities) to unexpectedly fail. To force SCons to re-run these tests rather than trusting the cached results, run scons with the option --config=force.

  • The following lists of options are not complete, they show only some commonly used options. The entire list of options can be found on the Configuration options page.

Common Options

Specifying Paths for Cantera's Dependencies

Python Module Options

Compiling the Cantera Python module requires that NumPy and Cython are installed for the target installation of Python. The following SCons options control how the Python module is built:

Windows Only Options

Note

The cantera.conf file uses the backslash character \ as an escape character. When modifying this file, backslashes in paths need to be escaped like this: boost_inc_dir = 'C:\\Program Files (x86)\\boost\\include' This does not apply to paths specified on the command line. Alternatively, you can use forward slashes (/) in paths.

  • In Windows there aren't any proper default locations for many of the packages that Cantera depends on, so you will need to specify these paths explicitly.

  • Remember to put double quotes around any paths with spaces in them, such as "C:\Program Files".

  • By default, SCons attempts to use the same architecture as the copy of Python that is running SCons, and the most recent installed version of the Visual Studio compiler. If you aren't building the Python module, you can override this with the configuration options target_arch and msvc_toolset_version.

  • To compile with MinGW, specify the :ref:`toolchain <toolchain-dev>` option:

    System Message: WARNING/2 (<string>, line 120); backlink

    Unknown reference target: toolchain-dev"

    toolchain=mingw
  • :ref:`msvc_toolset_version <_msvc-toolset-version-dev>`

    System Message: WARNING/2 (<string>, line 124); backlink

    Unknown reference target: _msvc-toolset-version-dev"

  • :ref:`msvc_version <msvc-version-dev>`

    System Message: WARNING/2 (<string>, line 125); backlink

    Unknown reference target: msvc-version-dev"

  • :ref:`target_arch <target-arch-dev>`

    System Message: WARNING/2 (<string>, line 126); backlink

    Unknown reference target: target-arch-dev"

  • :ref:`toolchain <toolchain-dev>`

    System Message: WARNING/2 (<string>, line 127); backlink

    Unknown reference target: toolchain-dev"

MATLAB Toolbox Options

Building the MATLAB toolbox requires an installed copy of MATLAB, and the path to the directory where MATLAB is installed must be specified using the following option:

Fortran Module Options

Building the Fortran module requires a compatible Fortran compiler. SCons will attempt to find a compatible compiler by default in the PATH environment variable. The following options control how the Fortran module is built:

Documentation Options

The following options control if the documentation is built:

Less Common Options

Build Commands

The following commands are possible as arguments to SCons:

scons command
  • scons help

    Print a list of available SCons commands.

  • scons help --options

    Print a description of user-specifiable options.

  • scons build

    Compile Cantera and the language interfaces using default options.

  • scons clean

    Delete files created while building Cantera.

  • scons install

    Install Cantera.

  • scons uninstall

    Uninstall Cantera.

  • scons test

    Run all tests which did not previously pass or for which the results may have changed.

  • scons test-reset

    Reset the passing status of all tests.

  • scons test-clean

    Delete files created while running the tests.

  • scons test-help

    List available tests.

  • scons test-NAME

    Run the test named NAME.

  • scons <command> dump

    Dump the state of the SCons environment to the screen instead of doing <command>, for example, scons build dump. For debugging purposes.

  • scons samples

    Compile the C++ and Fortran samples.

  • scons msi

    Build a Windows installer (.msi) for Cantera.

  • scons sphinx

    Build the Sphinx documentation

  • scons doxygen

    Build the Doxygen documentation

Compile Cantera & Test

  • Run SCons with the list of desired configuration options:

    scons build ...
    
  • If Cantera compiles successfully, you should see a message that looks like:

    *******************************************************
    Compilation completed successfully.
    
    - To run the test suite, type 'scons test'.
    - To list available tests, type 'scons test-help'.
    - To install, type 'scons install'.
    *******************************************************
  • If you do not see this message, check the output for errors to see what went wrong. You may also need to examine the contents of config.log.

  • Cantera has a series of tests that can be run with the command:

scons test
  • When the tests finish, you should see a summary indicating the number of tests that passed and failed.

  • If you have tests that fail, try looking at the following to determine the source of the error:

    • Messages printed to the console while running scons test

    • Output files generated by the tests

Building Documentation

To build the Cantera HTML documentation, run the commands:

scons doxygen
scons sphinx

or append the options sphinx_docs=y and doxygen_docs=y to the build command:

scons build doxygen_docs=y sphinx_docs=y