gcc 4.9.1 in OS X Yosemite - gcc: warning: couldn’

2020-02-08 04:02发布

问题:

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?

回答1:

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.



回答2:

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



回答3:

if you're using Homebrew, simply:

brew upgrade gcc


回答4:

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.



回答5:

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


回答6:

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.



回答7:

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?



回答8:

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


回答9:

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.



回答10:

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!