CMake“NMake Makefiles”发电机无法编译 [英] CMake "NMake Makefiles" generator fails to compile

查看:6548
本文介绍了CMake“NMake Makefiles”发电机无法编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从本教程编译简单的应用程序:
https:// www .johnlamp.net / cmake-tutorial-1-getting-started.html
(只是main.cc,ToDo.cc和ToDo.h文件)。

I'm compiling simple application from this tutorial: https://www.johnlamp.net/cmake-tutorial-1-getting-started.html (just main.cc, ToDo.cc and ToDo.h files).

我安装了Visual Studio 2015,当我使用它的生成器,VS项目成功生成:

I have Visual Studio 2015 installed and when I use it's generator, VS project is generated successfully:

PS C:\data\OtherTech\cmaketest\build> cmake "Visual Studio 14 2015" ..

但是,如果我使用NMake Makefiles Makefile生成器:

However, if I use "NMake Makefiles" or "Unix Makefiles" generators:

PS C:\data\OtherTech\cmaketest\build> cmake "NMake Makefiles" ..

我收到以下错误:

> PS C:\data\OtherTech\cmaketest\build> cmake -G "NMake Makefiles" ..
-- The C compiler identification is MSVC 19.0.23026.0
-- The CXX compiler identification is MSVC 19.0.23026.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
CMake Error at C:/Users/user1/Desktop/Apps/cmake-3.4.0-win32-x86/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (
message):
  The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
  14.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/Data/OtherTech/cmaketest/build/CMakeFiles/CMakeTmp



  Run Build Command:"nmake" "/NOLOGO" "cmTC_6fd86\fast"

        "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe" -f
  CMakeFiles\cmTC_6fd86.dir\build.make /nologo -L
  CMakeFiles\cmTC_6fd86.dir\build

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

        C:\PROGRA~2\MICROS~3.0\VC\bin\cl.exe
  @C:\Users\user1\AppData\Local\Temp\nm5A8B.tmp

  testCCompiler.c

  Linking C executable cmTC_6fd86.exe

        C:\Users\user1\Desktop\Apps\cmake-3.4.0-win32-x86\bin\cmake.exe -E
  vs_link_exe --intdir=CMakeFiles\cmTC_6fd86.dir --manifests --
  C:\PROGRA~2\MICROS~3.0\VC\bin\link.exe /nologo
  @CMakeFiles\cmTC_6fd86.dir\objects1.rsp
  @C:\Users\user1\AppData\Local\Temp\nm5B29.tmp

  The parameter is incorrectRC Pass 1 failed to run.

  NMAKE : fatal error U1077:
  'C:\Users\user1\Desktop\Apps\cmake-3.4.0-win32-x86\bin\cmake.exe' :
  return code '0xffffffff'

  Stop.

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

  Stop.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Data/OtherTech/cmaketest/build/CMakeFiles/CMakeOutput.log".
See also "C:/Data/OtherTech/cmaketest/build/CMakeFiles/CMakeError.log".

此外,如果我看看CMakeFiles\CMakeError.log

Also, if I look at CMakeFiles\CMakeError.log

它包含错误:

LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'

这里是完整的输出:

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe 
Build flags: 
Id flags: 

The output was:
2
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeCCompilerId.c
Microsoft (R) Incremental Linker Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:CMakeCCompilerId.exe 
CMakeCCompilerId.obj 
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe 
Build flags: 
Id flags: 

The output was:
2
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeCXXCompilerId.cpp
Microsoft (R) Incremental Linker Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:CMakeCXXCompilerId.exe 
CMakeCXXCompilerId.obj 
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'


Determining if the C compiler works failed with the following output:
Change Dir: C:/Data/OtherTech/cmaketest/build/CMakeFiles/CMakeTmp

Run Build Command:"nmake" "/NOLOGO" "cmTC_6fd86\fast"
    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe" -f CMakeFiles\cmTC_6fd86.dir\build.make /nologo -L                  CMakeFiles\cmTC_6fd86.dir\build

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

    C:\PROGRA~2\MICROS~3.0\VC\bin\cl.exe  @C:\Users\user1\AppData\Local\Temp\nm5A8B.tmp

testCCompiler.c

Linking C executable cmTC_6fd86.exe

    C:\Users\user1\Desktop\Apps\cmake-3.4.0-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_6fd86.dir --manifests  -- C:\PROGRA~2\MICROS~3.0\VC\bin\link.exe /nologo @CMakeFiles\cmTC_6fd86.dir\objects1.rsp @C:\Users\user1\AppData\Local\Temp\nm5B29.tmp

The parameter is incorrectRC Pass 1 failed to run.

NMAKE : fatal error U1077: 'C:\Users\user1\Desktop\Apps\cmake-3.4.0-win32-x86\bin\cmake.exe' : return code '0xffffffff'

Stop.

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

Stop.

我正在搜索有关此错误的信息,并发现可能我的PowerShell会话无权访问一些环境变量,所以我去了C:\Program Files(x86)\Microsoft Visual Studio 14.0 \VC并运行

I was searching for information about this error and figured out that perhaps my PowerShell session does not have access to some environment variables, so I went to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC and run

.\vcvarsall.bat

来配置环境,但这不幸没有帮助。

to configure the environment, but this unfortunately didn't help.

任何想法如何解决此问题?

Any ideas how to fix this issue?

推荐答案

来自Visual Studio Native Tools命令提示符的code> cmake 或 cmake-gui ,而不是纯命令提示符。这样所有必需的路径都正确设置和cmake可见。

Run cmake or cmake-gui from a Visual Studio Native Tools Command Prompt and not a plain command prompt. That way all the required paths are correctly setup and visible to cmake.

这篇关于CMake“NMake Makefiles”发电机无法编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆