30

I install OS X Yosemite and now i have a huge problem with gcc 4.9.1 compiler. I hope some one can help me please.

I try to compile my program and i have the warning message:

gcc: warning: couldn’t understand kern.osversion ‘14.0.0'

I search on google and i find https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61407 I try to apply the patch doing:

sudo patch -p1 < /usr/local/bin/00-darwin-10.10.patch

in gcc folder: /usr/local/bin/gcc and i received the message:

can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
|index dd45802..0db14d7 100644
|--- a/fixincludes/fixincl.x
|+++ b/fixincludes/fixincl.x
--------------------------
File to patch:

in File to patch: i already tried gcc and i received the message:

patching file gcc
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 15.
Hunk #3 succeeded at 1274 with fuzz 2 (offset -7908 lines).
Hunk #4 FAILED at 1319.
Hunk #5 FAILED at 1548.
Hunk #6 FAILED at 2671.
patch: **** Can't rename file gcc to gcc.orig : Permission denied

I try with sudo and i received:

can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
|index dd45802..0db14d7 100644
|--- a/fixincludes/fixincl.x
|+++ b/fixincludes/fixincl.x
--------------------------
File to patch: 

I´m in the wrong folder? Anyone can help me?

gsamaras
  • 71,951
  • 46
  • 188
  • 305
MMax
  • 311
  • 1
  • 3
  • 7
  • You may want to try gcc4.9.1 from macports, I'm using it and it works (I've also found a bug there but has been fixed in the same day I reported it, https://trac.macports.org/ticket/45483). So before installing make sure you update/upgrade your macports. – vsoftco Oct 21 '14 at 12:41
  • JFTR, I also got the message about incomprehensible `kern.osversion '14.0.0` (with asymmetric quote) from a home-built GCC 4.8.1 (built on Mavericks, or perhaps even Mountain Lion) when it ran on Yosemite as well as GCC 4.9.1. It is 'just a warning' — the compiler ran and produced an executable that ran OK. My [`valgrind`](http://valgrind.org/) is going to need rebuilding, at minimum - it dies with `Killed: 9`. – Jonathan Leffler Oct 21 '14 at 14:44

10 Answers10

32

I had a similar issue when building things from source, and it was because I forgot to install the updated command line tools after upgrading to Yosemite and xcode 6.1. Try this in your command line:

xcode-select --install 

That will download and install the command line tools and may fix your problem.

jfraser
  • 421
  • 3
  • 3
21

If you set MACOSX_DEPLOYMENT_TARGET=10.9 in your environment prior to compiling, the shared object linking should work properly.

Maysam Torabi
  • 3,672
  • 2
  • 28
  • 31
7

if you're using Homebrew, simply:

brew upgrade gcc
TomDunning
  • 4,829
  • 1
  • 26
  • 33
  • On my system this didn't work, but `brew upgrade gcc49` did the job – carlodef Feb 13 '15 at 11:41
  • I am having a similar problem with gcc 4.9.0 in BigSur 11.16.2. Simply `gcc --version` and I get " gcc: warning: couldn’t understand kern.osversion ‘20.6.0 " . I just open a new question about it (because the kern.osversion is similar, not the same). Also, I tried the `xcode-selec --install` and `brew upgrade gcc' fixes, but it did not worked for me. – Diving Jan 11 '22 at 15:36
7

This was enough for me, and it doesn't require any symlink:

export CC=/Applications/Xcode.app/Contents/Developer/usr/bin/gcc

After that, just run the command as usual.

Alfredo Di Napoli
  • 2,281
  • 3
  • 22
  • 28
  • Tried the various other solutions and this is the only one that worked for me. Xcode-select version 2343 : El Capitan version 10.11.6 – David Oct 19 '16 at 08:37
  • It should be noted that `/Applications/Xcode.app/Contents/Developer/usr/bin/gcc` is not GCC at all; it's just a convenience synonym for LLVM/Clang. If the OP actually needed `gcc` (or `gfortran` or whatever), then this would not help. But it certainly helps if you don't mind using the system LLVM/Clang. (But in that case, why would you install GNU GCC from Homebrew in the first place?) – Quuxplusone Sep 27 '17 at 06:04
4

This solve my problem: I link gcc with /Applications//Xcode.app/Contents/Developer/usr/bin/gcc

cd /usr/local/bin
ln -s /Applications//Xcode.app/Contents/Developer/usr/bin/gcc gcc
William Wong Garay
  • 1,921
  • 18
  • 14
  • Worked for me on 10.10 with ruby 2.1.5 and Xcode 6.3. I have spent 2 days crawling SO and trying to find the solution, this was the one for me. – IanBussieres Apr 13 '15 at 20:41
3

The patch you are trying to use is for patching the source code of GCC, and you are trying to use it to patch the compiled binary. That won't work.

In theory the process would be

  • Download source tarball of GCC compiler
  • apply the patch to it
  • compile GCC
  • Install the compiled GCC

However, you are unlikely to be able to do this since you cannot run the compiler in order to compile a newer copy of itself. Catch-22!

Searching google for 'gcc yosemite' I found a number of references to possible solutions, eg. enter link description here. I'm afraid I am no mac expert so I cannot judge the quality of these solutions.

harmic
  • 28,606
  • 5
  • 67
  • 91
2

I am also getting the warning "couldn't understand kern.osversion `14.0.0'" on GFORTRAN compilations while running Yosemite (10.10.1) with Xcode 6.1 and GCC 5.0. The compiler, however, generates functioning executable code and it seems to run correctly. Maybe you can just ignore the warning?

Tim Cohn
  • 21
  • 1
  • the problem behind this issue is not exactly trivial...it causes problems when installing MPICH2 and other software that should otherwise work correctly on Yosemite – William Jan 08 '15 at 00:17
0

I solved an issue by linking

export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
Xentatt
  • 1,264
  • 22
  • 35
0

It seems to want a current version of XCode command line tools. When I first typed "make" after installing Yosemite I got a warning and a dialog box saying that I did not have XCode command line tools and asked if I wanted to install them. I did so, and everything worked.

However one user did not get this dialog and instead got the error message as shown. The "xcode-select --install" did not work, so it seems like it may have kept the outdated command line tools and header files.

The MACOSX_DEPLOYMENT_TARGET=10.9 solution did work for him. However the compiles seemed to be a lot slower.

darinbob
  • 41
  • 2
0

I had this issue, installed Xcode cli tools (xcode-select --install), and still had issues. I'd upgraded from Yosemite to Mojave, and uninstalling an older version of the compiler worked for me:

brew uninstall apple-gcc42

Hope this helps someone!

JPowell
  • 418
  • 4
  • 6