如何使用MSVC 2015构建CMake项目?

raogr8fs  于 2022-11-24  发布在  其他
关注(0)|答案(1)|浏览(252)

我尝试使用MSVC 2015构建CMake(v3.14)项目。我使用CMake GUI生成makefile,但当我点击“配置”按钮时,我收到以下错误:

The C compiler identification is MSVC 19.0.24210.0
The CXX compiler identification is MSVC 19.0.24210.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Projets/geolibextern/build_msvc/CMakeFiles/CMakeTmp
    
    Run Build Command(s):nmake /nologo cmTC_fa317\fast 
        "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe" -f CMakeFiles\cmTC_fa317.dir\build.make /nologo -L                  CMakeFiles\cmTC_fa317.dir\build

    Building C object CMakeFiles/cmTC_fa317.dir/testCCompiler.c.obj

        C:\PROGRA~2\MICROS~2.0\VC\bin\amd64\cl.exe @C:\Users\egrace\AppData\Local\Temp\nm88C7.tmp

    testCCompiler.c

    Linking C executable cmTC_fa317.exe

        "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_fa317.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MICROS~2.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\cmTC_fa317.dir\objects1.rsp @C:\Users\egrace\AppData\Local\Temp\nm8993.tmp

    RC Pass 1: command "rc /foCMakeFiles\cmTC_fa317.dir/manifest.res CMakeFiles\cmTC_fa317.dir/manifest.rc" failed (exit code 0) with the following output:
    Le fichier sp‚cifi‚ est introuvableNMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'

    Stop.

    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'

    Stop.

我还尝试重新安装Visual C++生成工具或使用更新版本的CMake(未成功)。

sqxo8psd

sqxo8psd1#

实际上,CMake找不到程序mt.exe,因为Windows SDK文件夹不在PATH变量中。要解决这个问题,我需要使用以下参数执行此命令:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 8.1

相关问题