Back to LAMMPS Packages for Windows Overview

Building Windows Installer Packages with MinGW64 Cross-compilers on Fedora Linux

This page describes the process of building installer packages for Windows using the MinGW64 cross-compiler toolchain as bundled with Fedora Linux. There are two reasons for this:

  • 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.
  • LAMMPS is not ported to the "native" Visual C++ compilers but does support the MinGW64 toolchain, which is available as a native and a cross-compiler.

    An alternative for running LAMMPS on Windows machines 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.

    Prerequisites

    The cross-compilation is currently performed and tested on Fedora Linux 32 with the (many) prerequisite rpm packages installed that are listed below. A simpler way to obtain a compatible build environment is to download and use the Fedora32-MinGW singularity image for LAMMPS development with

            singularity pull --arch amd64 fedora32_mingw.sif library://lammps/default/lammps_development:fedora32_mingw
            singularity shell fedora32_mingw.sif
          

    Here is the list of packages which should be installed (and their dependencies):

    The cmake-win-on-linux.py script

    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 lammps-packages directory.

    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
      -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 cmake-win-on-linux.py script evolves as LAMMPS versions change, so it should be regularly updated when compiling newer LAMMPS versions.

    Compiling LAMMPS and building the installer package

    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: Sat Oct 17 02:27:12 UTC 2020 by akohlmey