C++ OS X Yosemite 中的 gcc 4.9.1 - gcc:警告:无法理解 kern.osversion '14.0.0'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26486163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:37:15  来源:igfitidea点击:

gcc 4.9.1 in OS X Yosemite - gcc: warning: couldn’t understand kern.osversion ‘14.0.0'

c++cgccosx-yosemite

提问by MMax

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.

我安装了 OS X Yosemite,现在我在 gcc 4.9.1 编译器上遇到了一个大问题。我希望有人可以帮助我。

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=61407I try to apply the patch doing:

我在谷歌上搜索,发现https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61407我尝试应用补丁:

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

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

在 gcc 文件夹中:/usr/local/bin/gcc我收到了消息:

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:

File to patch:我已经尝试过 gcc 并且我收到了消息:

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 sudoand i received:

我尝试sudo并收到:

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?

我在错误的文件夹中?任何人都可以帮助我吗?

回答by jfraser

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:

我在从源代码构建东西时遇到了类似的问题,这是因为我在升级到 Yosemite 和 xcode 6.1 后忘记安装更新的命令行工具。在命令行中试试这个:

xcode-select --install 

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

这将下载并安装命令行工具,并可能解决您的问题。

回答by Maysam Torabi

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

如果您MACOSX_DEPLOYMENT_TARGET=10.9在编译之前在您的环境中进行设置,则共享对象链接应该可以正常工作。

回答by TomDunning

if you're using Homebrew, simply:

如果您使用的是 Homebrew,只需:

brew upgrade gcc

回答by Alfredo Di Napoli

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.

之后,只需像往常一样运行命令。

回答by William Wong Garay

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

这解决了我的问题:我将 gcc 与 /Applications//Xcode.app/Contents/Developer/usr/bin/gcc 链接

cd /usr/local/bin
ln -s /Applications//Xcode.app/Contents/Developer/usr/bin/gcc gcc

回答by harmic

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.

您尝试使用的补丁是用于修补 GCC 的源代码,而您正在尝试使用它来修补已编译的二进制文件。那行不通。

In theory the process would be

理论上这个过程是

  • Download source tarball of GCC compiler
  • apply the patch to it
  • compile GCC
  • Install the compiled GCC
  • 下载 GCC 编译器的源码包
  • 将补丁应用到它
  • 编译 GCC
  • 安装编译好的 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!

但是,您不太可能做到这一点,因为您无法运行编译器来编译自身的较新副本。第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.

在谷歌搜索“gcc yosemite”,我发现了许多可能的解决方案的参考,例如。在此处输入链接描述。恐怕我不是 mac 专家,所以我无法判断这些解决方案的质量。

回答by Tim Cohn

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?

在使用 Xcode 6.1 和 GCC 5.0 运行 Yosemite (10.10.1) 时,我还在 GFORTRAN 编译中收到警告“无法理解 kern.osversion `14.0.0'”。然而,编译器会生成可运行的可执行代码,并且它似乎可以正确运行。也许你可以忽略警告?

回答by Dmytro Uhnichenko

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

回答by darinbob

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.

它似乎需要当前版本的 XCode 命令行工具。当我在安装 Yosemite 后第一次输入“make”时,我收到一个警告和一个对话框,说我没有 XCode 命令行工具,并询问我是否想安装它们。我这样做了,一切都奏效了。

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.

但是,一位用户没有收到此对话框,而是收到了如图所示的错误消息。“xcode-select --install”不起作用,所以它似乎保留了过时的命令行工具和头文件。

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

MACOSX_DEPLOYMENT_TARGET=10.9 解决方案确实对他有用。然而,编译似乎要慢得多。

回答by JPowell

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:

我遇到了这个问题,安装了 Xcode cli 工具 ( xcode-select --install),但仍然有问题。我从优胜美地升级到 Mojave,卸载旧版本的编译器对我有用:

brew uninstall apple-gcc42

Hope this helps someone!

希望这可以帮助某人!