CMAKE错误:“无法打开源文件” :'CMakeCCompilerId.c' [英] CMAKE error: "Cannot open source file" : 'CMakeCCompilerId.c'

查看:2589
本文介绍了CMAKE错误:“无法打开源文件” :'CMakeCCompilerId.c'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行在Windows和Linux上均可运行的CMAKE项目。当我尝试运行CMAKE生成生成文件时,出现以下错误:

I am trying to run a CMAKE project that works on Windows and on Linux. When I try to run CMAKE to generate the build files I get the following error:

我检查了该错误的其他帖子,其中大多数建议重新安装Visual Studio,但这无济于事。

I checked other posts for this error, most of which suggested reinstalling Visual Studio, but that did not help.

检查错误日志给我这个:

Checking the error logs gave me this:

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

The output was:
1
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 1/11/2019 15:31:21.
Project "C:\Users\user\Documents\projects\dsa_opengl_examples\build\CMakeFiles\3.13.2\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\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
  CMakeCCompilerId.c
c1 : fatal error C1083: Cannot open source file: 'CMakeCCompilerId.c': No such file or directory [C:\Users\user\Documents\projects\dsa_opengl_examples\build\CMakeFiles\3.13.2\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "C:\Users\user\Documents\projects\dsa_opengl_examples\build\CMakeFiles\3.13.2\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.

Build FAILED.

"C:\Users\user\Documents\projects\dsa_opengl_examples\build\CMakeFiles\3.13.2\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(ClCompile target) -> 
  c1 : fatal error C1083: Cannot open source file: 'CMakeCCompilerId.c': No such file or directory [C:\Users\user\Documents\projects\dsa_opengl_examples\build\CMakeFiles\3.13.2\CompilerIdC\CompilerIdC.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.02

有人知道我如何解决 c1:致命的错误C1083:无法打开源文件:'CMakeCCompilerId.c':没有这样的文件或目录 错误?

Does anyone know how I can solve the c1 : fatal error C1083: Cannot open source file: 'CMakeCCompilerId.c': No such file or directory error?

推荐答案

我遇到了同样的问题。

I had the same exact issue.

跟随@ serg06链接到部分解决方案后(并将其翻译成中文),我找到了解决方案:

After following @serg06 link to the partial solution (and translating it from Chinese) I have found the solution for me:

我使用的是来自WSL的git和来自cmd的cmake,不确定为什么一个问题,但是为Windows安装git并从cmd重新克隆我的repo解决了该问题。
希望有帮助!

I was using git from WSL and cmake from cmd, not sure why that is a problem, but installing git for windows and recloning my repo from cmd fixed the issue. Hope that helps!

这篇关于CMAKE错误:“无法打开源文件” :'CMakeCCompilerId.c'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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