在cygwin终端运行时显示不存在的文件夹

cmake error showing nonexistent folder on running in cygwin terminal

本文关键字:不存在 文件夹 显示 运行时 cygwin 终端      更新时间:2023-10-16

我正在尝试使用cmake在cygwin(在windows 8中)编译c++库g20。我创建了一个构建文件夹,当我尝试在该文件夹中执行cmake时,它会失败,并出现以下错误

$ cmake ../
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is GNU 4.8.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/cc" is not able to compile a simple test program.
  It fails with the following output:
   Change Dir: /cygdrive/b/g2o/trunk/build/CMakeFiles/CMakeTmp

  Run Build Command:/cygdrive/c/Program
  Files/MATLAB/R2009a/bin/win64/gmake.exe "cmTryCompileExec3795381385/fast"
  C:/Program Files/MATLAB/R2009a/bin/win64/gmake -f
  CMakeFiles/cmTryCompileExec3795381385.dir/build.make
  CMakeFiles/cmTryCompileExec3795381385.dir/build
  gmake[1]: Entering directory `B:/g2o/trunk/build/CMakeFiles/CMakeTmp'
  /usr/bin/cmake.exe -E cmake_progress_report "/cygdrive/b/g2o/trunk/build/CMakeFiles/CMakeTmp/CMakeFiles" 1
  Building C object
  CMakeFiles/cmTryCompileExec3795381385.dir/testCCompiler.c.o
  /usr/bin/cc -o CMakeFiles/cmTryCompileExec3795381385.dir/testCCompiler.c.o
  -c "/cygdrive/b/g2o/trunk/build/CMakeFiles/CMakeTmp/testCCompiler.c"
  Linking C executable cmTryCompileExec3795381385.exe
  /usr/bin/cmake.exe -E cmake_link_script
  CMakeFiles/cmTryCompileExec3795381385.dir/link.txt --verbose=1
  gmake[1]: Leaving directory `B:/g2o/trunk/build/CMakeFiles/CMakeTmp'
  process_begin: CreateProcess(NULL, /usr/bin/cmake.exe -E cmake_link_script
  CMakeFiles/cmTryCompileExec3795381385.dir/link.txt --verbose=1, ...)
  failed.
  make (e=2): The system cannot find the file specified.
  gmake[1]: *** [cmTryCompileExec3795381385.exe] Error 2
  gmake: *** [cmTryCompileExec3795381385/fast] Error 2
  CMake will not be able to correctly generate this project.
 Call Stack (most recent call first):
 CMakeLists.txt:4 (PROJECT)

-- Configuring incomplete, errors occurred!

这里有趣的事情是我在我的机器上安装了cmake 3.0,错误显示为cmake 2.8.11.2。我在电脑里搜索了一下,找不到那个名字的文件夹。system path变量也包含正确的cmake bin文件夹的路径。

我想不出这个错误背后的原因。这是cygwin本身的问题吗?我能做些什么来避免这个错误?

需要注意的一点是,Cygwin有自己的CMake副本,即您所看到的2.8.11.2。该版本与您的Windows机器上的版本没有任何关系。您是否尝试使用Windows安装版本而不是Cygwin?

我认为问题来自没有在Cygwin中安装所有必需的编译器库。您可以尝试创建一个简单的c++文件,并尝试直接使用gcc编译它。如果失败了,你现在已经找到了CMake失败的原因。

除非有很好的理由,否则你应该考虑不要在Windows中使用Cygwin来运行CMake。

这个问题,至少对我来说,是c编译器不接受unix风格的路径。

解决方案是通过cygwin安装gcc。我安装的包应该是gcc-basegcc-cpp