Repository navigation
Building CFS on Windows
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.
- 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)
The PATH environment variable must contain the paths to the following scripts/executables:
-
setvars.batto setup the work environment for Intel oneAPI (likely inC:\Program Files\Intel\oneAPI) -
patch.exeto automatically download missing dependencies (likely inC:\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
This guide assumes that you have already cloned the source code and its submodules. If not, take a look here.
- Enter the top
cfsdirectory and create a new and empty folder where you want to place your build, e.g.build. - Enter the build folder and open the command line from it (e.g. by typing
cmdin the Windows Explorer address bar when inside the folder). - Type
setvarsin 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 callsetvarsany time you open a new command line window and start the process anew. - Open the CMake GUI. You can do this directly from the command line by typing
cmake-gui. Leave the command line terminal open! - In the CMake GUI, enter the paths to the source code and to your build folder (in our example
/cfsand/cfs/build, respectively). - Press "Configure" and select "NMake Makesfiles" (or "NMake Makesfiles JOM" if using Jom) as the generator.
- 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).
- After the first round of configurations, CMake lets you select various build options, e.g. what additional executables or dependencies you want to build.
- After you have made your selections, press "Configure" again until all options appear before white background.
- Then, press "Generate" to generate the makefile.
- Return to the command line and, depending on what generator you used with CMake, type
nmakeorjom(afterjomyou may add/J Xwith X being the number of CPU cores you want to use in your parallel build). - This will build openCFS together with the selected dependencies.
- 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.
- For the C & C++ compiler chose the MSVC compiler called
- 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
.libfiles differently in a debug build. For example, hdf5 libraries likelibhdf5.libbecomelibhdf5_D.liband so on. In this case, simply delete the_Dsuffix from the file names manually (they can be found in the/libsubfolder of your build directory), then run NMAKE/Jom again.
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.
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.