Skip to content

Building CFS on Windows

Mirror Bot edited this page Aug 31, 2026 · 6 revisions

This is a guide for building openCFS from source on Windows, using the Microsoft Visual Studio C++ compiler (MSVC) and the Intel oneAPI Fortran compiler, together with CMake and NMAKE/Jom as make system.

Required build tools

  • Microsoft Visual Studio 2022 (includes the MSVC compiler and NMAKE)
  • Intel oneAPI HPC Toolkit (includes the Intel Fortran Compiler and the required Math Kernel Library)
  • CMake (to generate NMAKE/Jom and other makefiles from the openCFS source)
  • Git for Windows
  • Optional: Jom (an NMAKE clone that uses parallelisation to speed up the build process)

Setting environment variables

The PATH environment variable must contain the paths to the following scripts/executables:

  • setvars.bat to setup the work environment for Intel oneAPI (likely in C:\Program Files\Intel\oneAPI)
  • patch.exe to automatically download missing dependencies (likely in C:\Program Files\Git\usr\bin)
  • If using Jom, its executable must also be in PATH
  • If you want to call CMake or its GUI from the command line, also set PATH accordingly

Depending on the options you chose during installation of the various programs, you may have to add these paths to PATH manually. You can test whether PATH is set correctly by calling the executable from the command line together with --help, e.g. patch --help and check whether there is valid output

Build process

This guide assumes that you have already cloned the source code and its submodules. If not, take a look here.

  1. Enter the top cfs directory and create a new and empty folder where you want to place your build, e.g. build.
  2. Enter the build folder and open the command line from it (e.g. by typing cmd in the Windows Explorer address bar when inside the folder).
  3. Type setvars in the command line. This sets up the MSVC and Intel work environment and makes sure all the compilers and libraries are found. You have to call setvars any time you open a new command line window and start the process anew.
  4. Open the CMake GUI. You can do this directly from the command line by typing cmake-gui. Leave the command line terminal open!
  5. In the CMake GUI, enter the paths to the source code and to your build folder (in our example /cfs and /cfs/build, respectively).
  6. Press "Configure" and select "NMake Makesfiles" (or "NMake Makesfiles JOM" if using Jom) as the generator.
  7. If MSVC and the Intel oneAPI Fortran compiler are not recognised as your default native compilers, check "Specify native compilers" and enter their paths in the following window (see here).
  8. After the first round of configurations, CMake lets you select various build options, e.g. what additional executables or dependencies you want to build.
  9. After you have made your selections, press "Configure" again until all options appear before white background.
  10. Then, press "Generate" to generate the makefile.
  11. Return to the command line and, depending on what generator you used with CMake, type nmake or jom (after jom you may add /J X with X being the number of CPU cores you want to use in your parallel build).
  12. This will build openCFS together with the selected dependencies.

Known issues & solutions

  • Linking to the Ginkgo library has caused issues in the past. You can simply deselect this dependency when configuring via CMake.
  • If CMake is unable to find MSVC and Intel compiler as your native compilers, you will have to specify their path.
    • For the C & C++ compiler chose the MSVC compiler called cl.exe. It is usually found under [program folder]\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\[version number]\bin\Hostx64\x64.
    • For the Fortran compiler choose the Intel oneAPI compiler called ifx.exe. It is usually found under [program folder]\Intel\oneAPI\compiler\latest\bin.
  • When building the debug version, you might get a linker error stating that some libraries can't be found. That's because some dependencies label their .lib files differently in a debug build. For example, hdf5 libraries like libhdf5.lib become libhdf5_D.liband so on. In this case, simply delete the _D suffix from the file names manually (they can be found in the /lib subfolder of your build directory), then run NMAKE/Jom again.

Advanced topics

Using precompiled dependencies

Once you have built dependencies, you can reuse them for different openCFS builds, saving you the time of downloading and compiling them again. Source code and precompiled dependencies can be found in your build folder under cfsdeps\cache\sources and cfsdeps\cache\precompiled, respectively. These are also the paths where a new build is going to look for any precompiled dependencies, so as long as the compiler versions match, you can simply copy the whole cfsdeps folder over to your new build location.

Compiling with Intel oneAPI alone

It is possible to build openCFS using the Intel oneAPI C/C++ compiler instead of MSVC. Just follow the steps above, but specify the path to the Intel C/C++ compiler (icx.exe) via CMake. Note: Recent versions of Intel compilers cannot build some dependencies (boost, muparser, vtk, flann). As a workaround, you can build those dependencies with MSVC and then use them for your Intel-only build by following the paragraph above. Be mindful, however, that you will have to rename the zip folders in cfsdeps\cache\precompiled to make them look like they were compiled using Intel compilers, i.e. change boost_1.78.0_WIN10_X86_64_C-MSVC-19.44.35214.0.zip to boost_1.78.0_WIN10_X86_64_C-IntelLLVM-2025.0.4.zip and the others accordingly.

Clone this wiki locally