Categories:
How to Build Elmer on Windows
As of this post, neither the build instructions on Elmer’s webpage nor the Elmer GitHub repo include instructions for how to build Elmer on Windows. Here is a succinct set of instructions (discovered in the previous post, which detailed the stumbling around that led me a solution).
- Clone the Elmer source code.
cd \repos
mkdir fem
cd fem
git clone git://www.github.com/ElmerCSC/elmerfem
- Install MSYS as explained on the MSYS2 website
- Run “MSYS MinGW 64-bit” from the Start menu
- Run the pacman commands documented on the MSYS2 website (verify that these are still current).
pacman -Syu
pacman -Syu
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
- Install the dependencies required for Elmer. NSIS is required to create a Windows installer for Elmer.
pacman -S mingw64/mingw-w64-x86_64-cmake
pacman -S mingw64/mingw-w64-x86_64-openblas
pacman -S mingw64/mingw-w64-x86_64-qt5
pacman -S mingw64/mingw-w64-x86_64-qwt-qt5
pacman -S mingw64/mingw-w64-x86_64-nsis
- Switch to the parent directory of the elmer repo using
cd /repos/fem
. Note that the elmer repo directory will have siblings such as build and install, so the separate parent directory (fem in this example) simplifies the directory organization. - Create the required directories and switch to the build directory.
# create folders required for building a local install
mkdir -p bundle_msys2/bin
mkdir -p bundle_qt5/bin
mkdir -p platforms
mkdir build
cd build
- Deploy the prerequisite binaries for Elmer (Solver, Mesh2D, and GUI):
mkdir -p ../install/bin/platforms/
# binaries required by ElmerSolver
cp /mingw64/bin/libgfortran-5.dll ../install/bin/
cp /mingw64/bin/libgcc_s_seh-1.dll ../install/bin/
cp /mingw64/bin/libopenblas.dll ../install/bin/
cp /mingw64/bin/libquadmath-0.dll ../install/bin/
cp /mingw64/bin/libwinpthread-1.dll ../install/bin/
# binaries required by Mesh2D
cp /mingw64/bin/libstdc++-6.dll ../install/bin/
# binaries required by ElmerGUI
cp /mingw64/bin/qwt-qt5.dll ../install/bin/
cp /mingw64/bin/libdouble-conversion.dll ../install/bin/
cp /mingw64/bin/libicuin69.dll ../install/bin/
cp /mingw64/bin/libicuuc69.dll ../install/bin/
cp /mingw64/bin/libpcre2-16-0.dll ../install/bin/
cp /mingw64/bin/libharfbuzz-0.dll ../install/bin/
cp /mingw64/bin/libmd4c.dll ../install/bin/
cp /mingw64/bin/libpng16-16.dll ../install/bin/
cp /mingw64/bin/zlib1.dll ../install/bin/
cp /mingw64/bin/libzstd.dll ../install/bin/
cp /mingw64/bin/libicudt69.dll ../install/bin/
cp /mingw64/bin/libfreetype-6.dll ../install/bin/
cp /mingw64/bin/libglib-2.0-0.dll ../install/bin/
cp /mingw64/bin/libgraphite2.dll ../install/bin/
cp /mingw64/bin/libintl-8.dll ../install/bin/
cp /mingw64/bin/libbz2-1.dll ../install/bin/
cp /mingw64/bin/libbrotlidec.dll ../install/bin/
cp /mingw64/bin/libpcre-1.dll ../install/bin/
cp /mingw64/bin/libiconv-2.dll ../install/bin/
cp /mingw64/bin/libbrotlicommon.dll ../install/bin/
cp /mingw64/share/qt5/plugins/platforms/qwindows.dll ../install/bin/platforms/
- Build Elmer. When cmake completes, a message will be displayed confirming that generation is done and that build files have been written to the build/ directory. Run make to start compiling the source code or
make install
to compile the sources then create a local installation in the install/ directory. Note that there are some folders (created using mkdir -p below) that don’t appear to be used in a local build but the build still expects them to exist. You can also specify a debug build by adding the-DCMAKE_BUILD_TYPE=Debug
define.
cmake -G "MSYS Makefiles" \
-DWITH_ELMERGUI:BOOL=TRUE \
-DWITH_MPI:BOOL=FALSE \
-DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_Fortran_COMPILER=c:/dev/msys64/mingw64/bin/gfortran.exe \
-DQWT_INCLUDE_DIR=c:/dev/msys64/mingw64/include/qwt-qt5/ \
-DWIN32:BOOL=TRUE \
-DCPACK_BUNDLE_EXTRA_WINDOWS_DLLS:BOOL=TRUE \
../elmerfem
make install
- To create a Windows installer (using NSIS), run the package target.
make package
Leave a Reply