简体   繁体   中英

Clang: 'cmath' file not found

I'm compiling my project with clang but I'm having an odd error:

[ 1%] Building CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
In file included from /home/travis/build/dominique120/miniature-adventure/src/actions.cpp:20:
In file included from /home/travis/build/dominique120/miniature-adventure/src/otpch.h:27:
/home/travis/build/dominique120/miniature-adventure/src/definitions.h:39:10: fatal error:
'cmath' file not found
 #include <cmath>
 ^
make: *** [all] Error 2

My actions.cpp line 20:

#include "otpch.h"

otpch.h line 27:

#include "definitions.h"

definitions.h line 31:

#include <cmath>

I made a few edits but I have no idea what is causing this error, edits here: https://github.com/dominique120/miniature-adventure/commits/master

PS: GCC just dumps a ton of errors: https://travis-ci.org/dominique120/miniature-adventure/jobs/21905513

After googling for a problem I was having on macOS, I came to your post. I am sharing a solution, even though it applies only to Mac users.

Chances are you upgraded Xcode (or it was upgraded for you) and you continue to use an old compilation scheme.

Determine which of the following directories actually exists on your disk:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/

and make sure that among your compilation switches you have -I along with a directory that exists.

I had the same issue on Ubuntu 22.04 with libstdc++-11-dev installed.

After doing:

sudo apt install libstdc++-12-dev

...the error went away.

It seems to occur with libstdc++-11 only?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM