-
-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fatal error: 'cmath' file not found #1333
Comments
This is almost surely at your end, and we have for example this issue pinned for RcppArmadillo (where a Fortran compiler is needed too). You may also try asking on r-sig-mac for macOS specific questions. Our package is in good standing at CRAN and that includes tests on different macOS hardware choices and R versions. The Rcpp FAQ also has an entry. I am a little removed from this as I only use Linux these days, but as you alluded to, Xcode is a requirement. @coatless has provided nice resources such as the one linked above for all these years. |
Also see https://mac.r-project.org/ and its
|
@sarahsamorodnitsky try updating xcode cli. |
Good call. Maybe the Sonomoa upgrade requires that as follow-up. |
Thank you both for the prompt responses. I don't see a software update for Xcode available. @coatless, I've taken a look at some of your resources (this and this).
Not sure if that is relevant or helpful. Do you have any other suggestions? I really appreciate the help. |
Okidokies, so Xcode should be installed. Is there anything in your ~/.Renviron or ~/.Rprofile? Open terminal and type: cat ~/.Renviron
cat ~/.Rprofile Check if there is any clang modifications present. |
No files were found when I ran the above code:
Is that a problem? Somewhere along the way of Googling around for solutions I think I might have removed these files. |
Whoops, I needed one more: cat ~/.R/Makevars ^ What's in that file? |
Also could not find that file:
|
Mmm, that's interesting. Are you running anything to switch between R versions? Do you have (I need to duck out at this point. I'll be back later tonight.) |
I am not running anything to switch between R versions, other than redownloading some packages. Here is what I get when I check the PATH:
It does look like anaconda3 is present. (Thanks again BTW for helping me figure this out) |
Ah..Most of us have better luck outside of Conda, and mixing can be tricky. If you are knowledgeable around Conda it can surely work .... but naively mixing may be a best idea. Rcpp essentially "just" needs R to know about and find its compiler. The simplest litmus test is still Rcpp::evalCpp("2 + 2") |
Ah, okay, I get the same error when I run |
I would try that -- see if just R + Xcode will work, |
So I've tried deleting anaconda and have confirmed it is no longer in the path:
Still running into the same error. Tried restarting the computer and redownloading Rcpp. |
I recall @jeroen bumped into something very similar that was resolved by reinstalling CLT:
If that doesn't help, can you share the output of:
It could be worth trying to reinstall command line tools, e.g.
You can also trace the include paths used by clang by adding the
Then, try executing
Note that |
@sarahsamorodnitsky Any luck? |
@kevinushey Your first suggestion seems to have solved the problem! Thank you all so much for your help!! |
@sarahsamorodnitsky Sounds like we can close this then as the reinstallation provided you with a working setup? |
I encountered a similar issue with RcppEigen ( |
I don't actually think these are issues with either Which in the year 2024 appears to still be a challenge on some OSs, alas. I wish we had means to make this more reliable on those OSs, I am not aware that we do. |
@eddelbuettel They aren't Rcpp issues but I imagine that people will land here each time they have an issue installing/using Rcpp packages. I think the best you can do is document the problem and the solution/workaround. No one can change Apple's mind :-) |
@sjmgarnier That is what I tried to say a minute ago:
If you have a PR to test things, please do not hold back and help us make Rcpp (and friends) better! Where I live, things like |
@eddelbuettel If I can think of something, I will certainly let you know. Right now, I just manually test my packages every time I update the command line tools on my Mac because I know someone at some point will report problems on my repos. |
@eddelbuettel It looks like Apple has fixed the issue somehow. The latest update of the CLT for Sequoia doesn't have the problem anymore. |
@sjmgarnier That is good to know so thank you for reporting back here! |
Hi there,
I have a .cpp script I wrote several months ago that I haven't touched in a bit. I source that script using sourceCpp() in my R script. I am now getting the error:
fatal error: 'cmath' file not found
I am working from a Mac with OS Sonoma 14.6.1. I just updated R to version 4.4.1 and redownloaded Rcpp and RcppArmadillo. I have copied below a minimally-reproducible example that I found through Hadley Wickham's book:
If I save the above code in a file called
text.cpp
and source it usingsourceCpp(test.cpp)
I get the following error:I wasn't able to find this specific error looking through previous Github issues and the listserv, but from similar ones I gathered it has something to do with my local machine, maybe with Xcode? I do not feel qualified to diagnose this myself since I'm very new to using Rcpp and C++. Hoping to get a bit of help or insight. Thank you in advance.
Sarah
The text was updated successfully, but these errors were encountered: