Disclaimer: the following instructions are not part of an official Cantera distribution and are posted here in the hope that they will help others to compile Cantera from scratch in a similar windows environment. While steps were successfully tested for Cantera 2.6 and various development versions (latest tested: 3.0.0b1) there is no guarantee that compilation will work, as Windows setups are highly user-specific. (Previous versions of this guide covered Cantera 2.4 and 2.5.1, but compilation has not been tested with current development tools.) In case you should have suggestions for improvement, please feel free to leave comments (or post on the Cantera Users' group as usual).
The installation instructions are slightly modified from Bryan Weber's recommendations on the Cantera forum. Windows-specific installation instructions that are not dependent on anaconda/miniconda are posted on the Cantera website.
Initial tests indicate that the installation process still works on Windows 11.
Install Anaconda (or miniconda) and run an update using
(base) > conda update --all
... using Anaconda's Python 3.7 version (Note that here and below the first part is the command prompt; the actual command starts after the '>'
character).
Install Visual Studio IDE
... tested for Community 2019 edition (Desktop development with C++) and ... Community 2022 edition.
Install a git client
... tested for git
Locate the x64 Native Tools Command Prompt in the Menu, right-click, select More > Open File Location, right-click on the shortcut, select Properties and copy the Target command. Depending on installation it may or may not look similar to
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
for VS Community Edition 2019 or
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
for VS Community Edition 2022.
Open an Anaconda Powershell Prompt; you should see the command line represented as (<env>) PS <path>>
,
where <env>
corresponds to the conda environment (e.g. base
), and <path>
is the current folder.
Set environment variables needed for compilation with
(base) PS <path>> . "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
and create a conda environment via
(base) PS <path>> conda create -n cantera-dev scons numpy cython ruamel_yaml libboost h5py ipython pytest
Set environment variables needed for compilation with
(base) PS <path>> . "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
and create a conda environment via
(base) PS <path>> conda create -n cantera-dev -c conda-forge scons numpy cython ruamel.yaml boost-cpp yaml-cpp eigen ipython pytest highfive pint
Here, the channel conda-forge
ensures that a recent version of SCons is used (tested for SCons 4.3.0).
Activate the new environment using
(base) PS <path>> conda activate cantera-dev
and change to a suitable folder used for compilation (instructions below use GitHub
, which should be a pre-existing folder), and clone the repository (or a fork thereof), e.g.
(cantera-dev) PS <path>> cd GitHub
(cantera-dev) PS <path>> git clone https://github.com/Cantera/cantera.git
(cantera-dev) PS <path>> cd cantera
Optional: in case you do not want to compile the latest development version, switch to a desired git branch, e.g. use
(cantera-dev) PS <path>> git checkout 2.4
in case you'd like to compile version 2.4.
Create a cantera configuration file cantera.conf to hold configuration options. For cantera < 2.6.0a4, the following
content is necessary (make sure to replace <user name>
with the appropriate folder name, and adjust other path information as needed):
prefix = 'C:/Users/<user name>/cantera'
boost_inc_dir = 'C:/Users/<user name>/anaconda3/envs/cantera-dev/Library/include'
to ensure that cantera is installed in the user directory (make sure this is different from the folder used for compilation;
also, replace anaconda3
by miniconda3
or any alternative conda installation path as necessary). In case you should
have multiple compilation toolchains installed, you may have to add
toolchain = 'msvc'
To install the MATLAB toolbox, also add
matlab_toolbox = 'y'
matlab_path = 'C:/Program Files/MATLAB/R20<XYz>'
with <XYz>
being the MATLAB version. Note that the MATLAB installation location may be different on your system.
Now that everything is configured, run
(cantera-dev) PS <path>\cantera> scons build
(cantera-dev) PS <path>\cantera> scons test
(cantera-dev) PS <path>\cantera> scons install
Prior to Cantera 2.6.0a4, the installation ends with
Cantera has been successfully installed.
File locations:
applications C:\Users\<user>\cantera\bin
library files C:\Users\<user>\cantera\lib
C++ headers C:\Users\<user>\cantera\include
samples C:\Users\<user>\cantera\samples
data files C:\Users\<user>\cantera\data
Python package (cantera) C:\Users\<user>\miniconda3\envs\cantera-dev\Lib\site-packages
Python samples C:\Users\<user>\miniconda3\envs\cantera-dev\Lib\site-packages\cantera\examples
Matlab toolbox C:\Users\<user>\cantera\matlab\toolbox
Matlab samples C:\Users\<user>\cantera\samples\matlab
An m-file to set the correct matlab path for Cantera is at:
C:\Users\<user>\cantera\matlab\toolbox\ctpath.m
scons: done building targets.
For Cantera >= 2.6.0a4, Cantera will be installed in subfolders of the conda environment.
Important: As the compiled code is based on the conda environment
cantera-dev
, it is only usable from within that environment. This means that in order to use your newly compiled Cantera version from Python or MATLAB, you have to activate yourcantera-dev
environment first. The easiest approach is to start an Anaconda Shell/Powershell, runconda activate cantera-dev
, and then launch your application from the command line. E.g.matlab
for MATLAB,ipython
for iPython,code
for Visual Studio Code, and similar. Visual Studio Community would bedevenv
, but needs its path added to the 'Path' environment variable first.