带有 Cygwin 的 CLion:g++.exe .../compiler-arguments.txt: No such file or directory 错误

CLion with Cygwin: g++.exe .../compiler-arguments.txt: No such file or directory error

在使用 Cygwin 的 CLion 中,当我尝试打开某个 c++ 项目时,在解析项目的 CMake 文件时出现以下错误:

Error:Configuration emdw [Debug]
Compiler exited with error code 1: g++ -xc++ -Demdw_EXPORTS -I/cygdrive/c/Users/Dirk/.CLion2016.2/system/cmake/generated/emdw-e21eebc3/e21eebc3/Debug/src -I/cygdrive/f/devel/emdw/src -I/cygdrive/f/devel -I/cygdrive/f/devel/patrecII/src -std=c++11 -O3 -g -Wall -v -dD -E
g++.exe: error: @/cygdrive/f/users/heetbeet/AppData/Local/Temp/compiler-arguments.txt: No such file or directory
g++.exe: error: /cygdrive/f/users/heetbeet/AppData/Local/Temp/compiler-file: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.

我认为 CLion 会生成这些类型的编译器-arguments.txt / 编译器文件,因为在实际的 CMake 结构中找不到此类指令。请注意,我可以从 Cygwin 的 bash 成功地 运行 cmake.exe 完成此项目,而不会出现任何错误。

CLion 试图通过 compiler-arguments.txt 文件(如果它是 CLion)实现什么魔力,我该如何开始调试这个问题?

我可以确认在 CLion 中单击 Reload CMake Project 按钮后,

compiler-arguments.txtcompiler-file两个文件确实是在F:\users\heetbeet\AppData\Local\Temp中创建的(即Cygwin中的/cygdrive/f/users/heetbeet/AppData/Local/Temp/)。

compiler-arguments.txt的内容是:

-xc++ -Demdw_EXPORTS -I/cygdrive/c/Users/Dirk/.CLion2016.2/system/cmake/generated/emdw-e21eebc3/e21eebc3/Debug/src -I/cygdrive/f/devel/emdw/src -I/cygdrive/f/devel -I/cygdrive/f/devel/patrecII/src -std=c++11 -O3 -g -Wall -v -dD -E -D___CIDR_IGNORE_DEFINITIONS_START

compiler-file包含一堆#if#ifdef,前20行为:

#define ___CIDR_IGNORE_DEFINITIONS_END
#if !(defined (__has_extension)) && defined(__has_feature)
  #define __has_extension __has_feature
#endif
#if !defined(__has_attribute)
  #define __has_attribute(x) 0
#endif
#ifdef __has_feature
#if __has_feature(cxx_constexpr)
____CIDR_test_query_feature->cxx_constexpr=1
#else
____CIDR_test_query_feature->cxx_constexpr=0
#endif
#if __has_feature(cxx_trailing_return)
____CIDR_test_query_feature->cxx_trailing_return=1
#else
____CIDR_test_query_feature->cxx_trailing_return=0
#endif
#if __has_feature(c_generic_selections)
____CIDR_test_query_feature->c_generic_selections=1
<...>

我们需要以某种方式创建源文件的 AST。为了使它正确,我们需要编译器特定的宏和功能 FOR EACH c/cpp-file 在您的项目中,因为您可以为每个更改编译器选项。这就是您在跨平台项目中为正确突出显示和宏观评估付出的代价。

关于问题:您使用的是cygwin,感觉可以通过调用chmod 777来解决问题。