在使用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会生成此类的editor-arguments.txt / compiler-file文件,因为在实际的CMake结构中找不到此类指令。请注意,我可以使用Cygwin的bash在此项目上成功运行
cmake.exe
,而不会出现任何错误。CLion试图通过
compiler-arguments.txt
文件实现什么魔术(如果是CLion),如何开始调试此问题?我可以确认单击CLion中的
Reload CMake Project
按钮后,实际上在
compiler-arguments.txt
中创建了两个分别名为compiler-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文件的特定于编译器的宏和功能,因为您可以更改每个宏的编译器选项。这就是您要在跨平台项目中正确突出显示和进行宏评估所要付出的代价。
关于此问题:您正在使用cygwin,我感觉可以通过chmod 777呼叫解决该问题。