2

I encountered this error while trying to build a cpp project using CLion. Here is the error message:

/usr/include/c++/5/cmath:102:11: error: ‘::acos’ has not been declared
   using ::acos;
           ^
/usr/include/c++/5/cmath:121:11: error: ‘::asin’ has not been declared
   using ::asin;
           ^
/usr/include/c++/5/cmath:140:11: error: ‘::atan’ has not been declared
   using ::atan;
           ^
/usr/include/c++/5/cmath:159:11: error: ‘::atan2’ has not been declared
   using ::atan2;
           ^
/usr/include/c++/5/cmath:180:11: error: ‘::ceil’ has not been declared
   using ::ceil;
           ^
/usr/include/c++/5/cmath:199:11: error: ‘::cos’ has not been declared
   using ::cos;

...

In the project, there is a custom header file called ~/someproject/src/math.h. Changing the ~/someproject/src/math.h file name to a non-conflicting name such as math1.h (and updating its references accordingly) resolves the error.

Does anybody know of another solution to this that does not require a name change?

arved
  • 4,401
  • 4
  • 30
  • 53
Zahra
  • 6,798
  • 9
  • 51
  • 76

1 Answers1

2

There are several solutions:

  • Use relative includes e.g. #include "../src/math.h
  • Use a patch component e.g. #include <src/math.h>
  • Fix your include path which seems to contain something like -I/usr/include, so that the standard include directories are included before your custom directories.

Reference: https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

arved
  • 4,401
  • 4
  • 30
  • 53