GROMACS version: 2022.4
GROMACS modification: Yes(Minor)
I tried to compile Gromacs 2022.4 on Win10 with Visual Studio 2022 Professional. When I set GMX_GPU=NO, I compiled correctly. However, when I set GMX_GPU=CUDA, VS showed multiple errors during compilation. I replaced CXX17 to CUDA17 in gmxManageNvccConfig.cmake and thus fixed the problem with -std:c++17. I also added error messages to static_assert
functions so that these files could be compiled. I added #include <tuple>
lines to some files to avoid undefined errors. Finally, no errors met during the second stage, but it encountered link error when generating gromacs.lib
. I found that the error may come from different type of runtime between the source code (MT) and my project(MD), but I have changed all the C++ code generation rules to MT, and the problem still exists.
Hope that someone could give me some solutions to solve this problem. Thank you!
I had exactly same problem when it was not possible to link gmx with CUDA files due to LNK2038 error. It is due to CMake uses MultiThreadedDLL as RuntimeLibrary value by default and this behaviour do not depend on shared/static options provided by Gromacs setup.
It is possible to change this behaviour using CMAKE_MSVC_RUNTIME_LIBRARY property introduced in CMake 3.15 (CMAKE_MSVC_RUNTIME_LIBRARY — CMake 3.26.0-rc6 Documentation). I have used “MultiThreaded$<$CONFIG:Debug:Debug>” value and build was successful. Also, I switch off build of shared libraries and gmx and swith on using of static libraries where possible.