首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CMAKE错误:“无法打开源代码文件”:'CMakeCCompilerId.c‘

CMAKE错误:“无法打开源代码文件”:'CMakeCCompilerId.c‘
EN

Stack Overflow用户
提问于 2019-01-11 23:44:04
回答 2查看 4.3K关注 0票数 3

我正在尝试运行一个在Windows和Linux上工作的CMAKE项目。当我试图运行CMAKE来生成构建文件时,我会得到以下错误:

我检查了其他帖子以了解此错误,其中大多数建议重新安装Visual,但没有帮助。

检查错误日志会给我以下结果:

代码语言:javascript
运行
复制
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 : fatal error C1083: Cannot open source file: 'CMakeCCompilerId.c': No such file or directory错误吗?

EN

回答 2

Stack Overflow用户

发布于 2019-11-19 16:56:27

我也有同样的问题。

在以下@serg06 06链接到部分解 (并将其翻译自中文)之后,我找到了解决方案:

我使用的是来自WSL的git和cmd中的cmake,不知道为什么会出现问题,但是为windows安装git并从cmd重新克隆我的repo解决了这个问题。希望这能帮上忙!

票数 1
EN

Stack Overflow用户

发布于 2019-11-13 07:47:16

经过3个小时的搜索,我终于找到了(部分)解。上面只写着:

  • 将项目文件夹(带有CMakeLists.txt的文件夹)复制到桌面上。
  • 在那里导航并再次运行cmake命令。
  • 它起作用了!

为什么它在桌面上工作,而不是在它原来的位置?毫无头绪。我认为这是权限问题,所以我最大限度地限制了原始文件夹的权限。(给予“每个人”和我自己完全的权限+赋予自己文件夹和子文件夹的所有权。)没什么区别。

我想我们只能在C:\Users\Myname\下的某个地方完成我的项目了。

如果这不能解决你的问题,我发现的其他解决办法是:

  • 重新安装cmake
  • 将信用评级下调至3.14.x
  • 重新安装VS
  • 确保指定正确的makefile生成器。(例如,如果您调用cmake -G "Visual Studio 12" .,您指的是VS 2013 (VS 12 = VS 2013)。参见所有生成器的cmake --help )。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54155471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档