2

(This is my first question ever on StackOverflow)

I have to use a Mac at work, and I'm coding in C++ with Code::Blocks (because I am used to this IDE). 2 days ago I upgraded from MacOS High Sierra to MacOS Mojave and I can fairly say that... it was a bad decision.

Now, when trying to #include <math.h> I get this error : fatal error: sys/cdefs.h: No such file or directory. I have tried to reinstall the xcode line command tools with xcode-select --install, but it still doesn't work.

Does anybody have a clue of what is going on, and how I could solve this issue ?

FlatKos
  • 17
  • 1
  • 6
  • have you tried to include cmath instead of math.h ? math.h is C not C++ cmath is the c++ equivalent (actually mostly a wrapper). – crashdog Sep 26 '18 at 12:34
  • Thanks for the tip, but it absolutely does not change anything :( – FlatKos Sep 26 '18 at 12:39
  • have you tried using the search function is OSX to see if the file actually exists anywhere ? If yes, you could add the location path in Code::Blocks. If not you probaly need to get the headers installed with brew or the likes. – crashdog Sep 26 '18 at 12:46
  • This is probably the answer you're looking for: https://stackoverflow.com/questions/19575956/building-c-not-working-in-osx-10-9 It appears that you have to download the cmd tools and install it rather then running xcode-slect --install. – crashdog Sep 26 '18 at 12:54
  • Ok thanks for your replies. Thanks to what I read on them, I tried to reinstall gcc, and it solved the problem. The location of headers must have changed between High Sierra and Mojave. – FlatKos Sep 26 '18 at 13:26

2 Answers2

2

The accepted answer doesn't seem to work for me, but this did:

cd /Library/Developer/CommandLineTools/Packages/
open .

and double clicking the pkg file.

Anti Earth
  • 4,671
  • 13
  • 52
  • 83
-1

Problem solved by reinstalling gcc. Location of headers has probably changed between High Sierra and Mojave.

I suggest to anyone encountering the same problem to do the same and also to (re)install the xcode line command tools with xcode-select --install

FlatKos
  • 17
  • 1
  • 6
  • Reinstalling gcc4.9 and gcc7 had no effect for me. However, using a direct path (`/usr/bin/gcc`) allowed me to compile – Anti Earth Nov 15 '18 at 15:54