Windows环境下编译Bellhopcuda二进制文件遇nmake缺失问题求助
我目前正在从事水下声学模拟工作,计划使用Bellhop工具集的Bellhopcxx或Bellhopcuda工具。在参考其他学生的指导编译二进制文件时遇到问题,命令行操作记录如下:
Microsoft Windows [Version 10.0.26100.8390] (c) Microsoft Corporation. All rights reserved. C:\Users\s1447548>git clone https://github.com/A-New-BellHope/bellhopcuda.git fatal: destination path 'bellhopcuda' already exists and is not an empty directory. C:\Users\s1447548>cd bellhopcuda/ C:\Users\s1447548\bellhopcuda>git submodule update --init --recursive C:\Users\s1447548\bellhopcuda>mkdir build A subdirectory or file build already exists. C:\Users\s1447548\bellhopcuda>cd build/ C:\Users\s1447548\bellhopcuda\build>cmake .. CMake Error at CMakeLists.txt:31 (project): Running 'nmake' '-?' failed with: no such file or directory -- Configuring incomplete, errors occurred! C:\Users\s1447548\bellhopcuda\build>
执行cmake步骤时提示找不到nmake工具,配置未完成,以下是解决思路:
安装并使用Visual Studio开发者命令提示符:nmake是Visual Studio自带的编译工具,需先安装Visual Studio并勾选「C++开发工具」组件。安装完成后,启动对应版本的Visual Studio开发者命令提示符,该环境会自动配置好nmake的路径,再重新执行cmake命令即可。
手动添加nmake路径到系统环境变量:找到Visual Studio安装目录下的nmake.exe所在路径(通常在
C:\Program Files (x86)\Microsoft Visual Studio\<你的VS版本>\BuildTools\bin或类似路径),将该路径添加到系统的PATH环境变量中,重启命令提示符后再尝试cmake操作。切换CMake生成器:若不想使用nmake,可指定其他兼容的生成器。比如使用MinGW的make工具,执行命令:
cmake .. -G "MinGW Makefiles"(需提前安装MinGW并将其bin目录加入PATH);或者使用Visual Studio的MSBuild生成器,执行命令:cmake .. -G "Visual Studio 17 2022"(根据你的VS版本调整版本号),之后通过MSBuild编译项目。
内容的提问来源于stack exchange,提问作者user21764386

