【问题标题】:Windows CMake Won't Compile Test ProgramWindows CMake 不会编译测试程序
【发布时间】:2023-03-31 00:59:01
【问题描述】:

我正在尝试使用 CLion 设置 C/C++ 环境,但 CMake 无法编译测试程序:

C:\Users\corey\.CLion2016.3\system\cygwin_cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/corey/ClionProjects/demo
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler: /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: /cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- broken
CMake Error at /cygdrive/c/Users/corey/.CLion2016.3/system/cygwin_cmake/share/cmake-3.6.2/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/cygdrive/c/Program Files (x86)/Microsoft Visual Studio
  12.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /cygdrive/c/Users/corey/ClionProjects/demo/cmake-build-debug/CMakeFiles/CMakeTmp



  Run Build Command:"/cygdrive/c/D/dmd2/windows/bin/make.exe"
  "cmTC_2a8fc/fast"

  f CMakeFiles/cmTC_2a8fc.dir/build.make CMakeFiles/cmTC_2a8fc.dir/build

  Error: 'f' not found





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


-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/corey/ClionProjects/demo/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/corey/ClionProjects/demo/cmake-build-debug/CMakeFiles/CMakeError.log".

我正在运行 Windows 10 和 VC 12.0(Visual Studio 2013?)。我尝试将 CLion 设置为使用 cygwin cmake 而不是内置版本,并且尝试重新安装所有相关工具,但没有成功。

【问题讨论】:

  • cygwin 中的 MSVC?你确定吗?
  • CLion 使用 cmake 和 cygwin 或 mingw,然后 cmake 默认使用 VC。
  • 看来切换它使用cygwin的GCC而不是VC没有区别,出现同样的错误。

标签: c++ windows cmake clion


【解决方案1】:

想通了 - 在输出的前几次错过了 - 我安装了 D lang DMD,无论出于何种原因,它都有自己的 make.exe。默认情况下,CMake 出于某种原因选择了这个 make 可执行文件,而不是 cygwin 中的那个。卸载 DMD 或手动配置 CMake 以使用 cygwin make 可以解决此问题。

【讨论】:

    猜你喜欢
    • 2021-03-18
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    相关资源
    最近更新 更多