Search code examples
c++cygwinclion

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


In CLion using Cygwin, when I try to open a certain c++ project, I get the following error when parsing the project's CMake file:

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.

I take it CLion generate these type of compiler-arguments.txt / compiler-file files, since no such instructions are found in the actual CMake structure. Note that I can successfully run cmake.exe on this project from Cygwin's bash without any errors.

What magic is CLion trying to achieve with the compiler-arguments.txt file (if it is CLion), and how do I begin to debug this problem?

I can confirm that upon clicking the Reload CMake Project button in CLion,

enter image description here

two files named compiler-arguments.txt and compiler-file are indeed created in F:\users\heetbeet\AppData\Local\Temp (that is /cygdrive/f/users/heetbeet/AppData/Local/Temp/ in Cygwin).

The content of compiler-arguments.txt is:

-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

The compiler-file contains a bunch of #if's, #ifdef's, with the first 20 lines as:

#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
<...>

Solution

  • We need to create AST of your source files somehow. To make it right we need the compiler-specific macros and features FOR EACH c/cpp-file in your project, because you can change the compiler option for each one. So that is the price you are paying for right highlighting and macro evaluation in cross-platform project.

    About the issue: you are using cygwin and I have feeling that the problem can be resolved by chmod 777 calls.