This page describes the process of building installer packages for Windows using the MinGW64 cross-compiler toolchain as bundled with Fedora Linux. The reason for this is that LAMMPS is developed primarily on Linux, so building the Windows executables with a cross-compiler allows using familiar tools and the process can be scripted and automated in the same way.
As of winter 2021/2022 it is also possible to build large parts of LAMMPS natively on Windows using the Microsoft Visual Studio C++ compilers when using the CMake build procedure, both from the command line and from within the Visual Studio IDE (which natively supports building with CMake). The selection of packages, that can be enabled and compiled natively is smaller because some of them expect a unix-like build environment or because they have not been fully ported to Windows but compile with the more "forgiving" runtime environment and GCC compilers used by the cross-compiler system.
An alternative for running LAMMPS on Windows machines with native executables is to install the Windows Subsystem for Linux on Windows 10 and then install or compile and run Linux executables in the embedded Ubuntu Linux subsystem with Bash on Windows.
The cross-compilation is currently performed and tested on Fedora Linux 35 with the (many) prerequisite rpm packages installed that are listed below. A simple way to obtain a compatible build environment is to build a singularity image with the description file provided in tools/singularity folder of the LAMMPS source code.Here is the list of packages which should be installed (and their dependencies):
As a next step, a clone or snapshot file of the
lammps-packages git repository from
https://github.com/lammps/lammps-packages is needed.
The scripts and files required to build Windows installer packages are located in the
mingw-cross folder inside the
This script performs all the tasks of downloading third party sources, packages and binaries, configuring, compiling, and packaging.
Below is a list of the supported command line options:
Usage: python3 cmake-win-on-linux.py -b <bits> -j <cpus> -p <mpi> -t <thread> -r <rev> -v <yes|no> -g <folder> -a <yes|no> Flags (all flags are optional, defaults listed below): -b : select Windows variant (default value: 64) -b 32 : build for 32-bit Windows -b 64 : build for 64-bit Windows -j : set number of CPUs for parallel make (default value: 8) -j <num> : set to any reasonable number or 1 for serial make -p : select message passing parallel build (default value: no) -p mpi : build an MPI parallel version with MPICH2 v1.4.1p1 -p no : build a serial version using MPI STUBS library -t : select thread support (default value: omp) -t omp : build with threads via OpenMP enabled -t no : build with thread support disabled -y : select python support (default value: no) -y yes : build with python included -y no : build without python -r : select LAMMPS source revision to build (default value: stable) -r stable : download and build the latest stable LAMMPS version -r unstable : download and build the latest patch release LAMMPS version -r master : download and build the latest development snapshot -r patch_<date> : download and build a specific patch release -r <sha256> : download and build a specific snapshot version -v : select output verbosity -v yes : print progress messages and output of make commands -v no : print only progress messages -g : select folder with git checkout of LAMMPS sources -g <folder> : use LAMMPS checkout in <folder> (default value: /home/akohlmey/compile/lammps-packages/mingw-cross/lammps) -a : select admin level installation (default value: yes) -a yes : the created installer requires to be run at admin level and LAMMPS is installed to be accessible by all users -a no : the created installer runs without admin privilege and LAMMPS is installed into the current user's appdata folder -a msix : same as "no" but adjust for creating a simpler MSIX package Example: python3 cmake-win-on-linux.py -r unstable -t omp -p mpi
Please note, that the
script evolves as LAMMPS versions change, so it should be regularly updated
when compiling newer LAMMPS versions.
After changing to a folder where the installer package or packages should be built, the python script is called and then a temporary directory is created - named after the various options selected - where the build is then performed. The script will print out messages about the progress of the build. With the option -v yes also, the screen output of all shell commands will be printed to the screen. At the end of the script run, the final installer package will be written to the current working directory, and the temporary folder and all its contents will be removed.
Last modified: Wed Feb 16 21:26:59 UTC 2022 by akohlmey