Intel oneAPI on Windows: linker error, cannot find m.lib
Summary
Trying to build GROMACS 2024.4 with oneAPI 2025.0 + MSVC 2022 on Windows fails: LINK : fatal error LNK1181: cannot open input file ‘m.lib’
Apparently, the reason is that IntelLLVM has libm.lib, so CMake sets HAVE_LIBM
to true, and so m
is added to the list of libraries. However, it should be libm
, not m
.
Exact steps to reproduce
Get GROMACS 2024.4 (or any other?), oneAPI 2025, MSVC 2022. Follow the installation instructions from https://www.intel.com/content/www/us/en/developer/articles/training/build-gromacs-with-intel-oneapi-dpc-c-compiler.html, specifically:
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icx -DGMX_GPU=SYCL -DGMX_FFT_LIBRARY=mkl -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=on
Possible fixes
CMake's find_library
correctly stores the library path to HAVE_LIBM
variable. We should use this value instead of hardcoded m
.