代码之家  ›  专栏  ›  技术社区  ›  Startec

CMAKE错误:“无法打开源文件”:“CMakeCCompilerId.c”

  •  0
  • Startec  · 技术社区  · 6 年前

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

    enter image description here

    我查看了其他帖子中的错误,其中大部分建议重新安装visualstudio,但这没有帮助。

    通过检查错误日志,我发现:

    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 错误?

    0 回复  |  直到 6 年前
        1
  •  1
  •   Omer Cohen    5 年前

    我也有同样的问题。

    the partial solution (并翻译成中文)我找到了解决办法:

    希望有帮助!

        2
  •  0
  •   serg06    6 年前

    经过3个小时的搜寻,我终于找到了 a (partial) solution . 它只说:

    • 在那里导航并再次运行cmake命令。
    • 它起作用了!

    为什么它能在桌面上工作,但不能在原来的位置工作?没有线索。我认为这是权限问题,所以我用尽了我原来文件夹的权限。(给“每个人”和“我自己”完全权限+给自己文件夹和子文件夹所有权。)没有区别。

    我想我们只能接受我的计划了 C:\Users\Myname\ .

    如果这不能解决你的问题,我找到的其他解决方案是:

    • Reinstalling cmake
    • 请确保指定正确的生成文件生成器。(例如,如果你打电话 cmake -G "Visual Studio 12" . ,你指的是VS 2013(VS 12=VS 2013)。看到了吗 cmake --help 所有发电机。)
    推荐文章