【问题标题】:CMake Visual Studio 2015 C compiler is unknownCMake Visual Studio 2015 C 编译器未知
【发布时间】:2016-10-25 22:19:46
【问题描述】:

我第一次尝试使用 cmake 来使用 Visual Studio 2015 编译一个旧的 c 项目,但是我不断收到 c 编译器未知。 cmake的错误如下;

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: 
Id flags: 

The output was:
1
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 23/06/2016 14:46:48.
Project "D:\Modules\cmake-test\build\CMakeFiles\3.6.0-    rc3\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /nologo /W0 /WX- /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TC /analyze- /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X86 /SAFESEH Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1158: cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe' [D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) -> 
LINK : fatal error LNK1158: cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe' [D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj]

   0 Warning(s)
   1 Error(s)

Time Elapsed 00:00:00.39

我查看了这些答案,但没有找到可行的解决方案。

Cmake Visual Studio 2015 Identification Unknown

CMake cannot identify C compiler from installed Visual Studio 2015

CMake does not find Visual C++ compiler

C compiler identification is unknown despite setting CC and CXX variables

我使用的命令是

cmake -G "Visual Studio 14 2015" .

我已经尝试过 3.6.0-rc3 和 3.5.2 版本的 cmake。

按照这个问题的说明,我在我的路径上获得了 rc.exe。

Visual Studio can't build due to rc.exe

任何帮助将不胜感激!

【问题讨论】:

  • 能否请您提供您尝试过的cmake 命令行?看起来像nmake
  • 已更新问题,因为已经尝试过该链接
  • @Florian 我更新了问题
  • 错误显示cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe'。可以从命令行试试吗?

标签: c visual-studio-2015 cmake


【解决方案1】:

从控制面板进入 MSVC 设置,修改安装并设置此标志

(对我来说,从 M$ 网站安装 SDK 奇怪地没有帮助)

【讨论】:

    猜你喜欢
    • 2016-09-02
    • 2019-10-31
    • 1970-01-01
    • 1970-01-01
    • 2015-12-30
    • 1970-01-01
    • 2017-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多