为什么Homebrew报告"无法理解kern.osversion`14.0.0'"?

oro*_*ome 5 xcode homebrew command-line gcc llvm-gcc

当我跑步时,brew -- config我得到了

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: bc071fb5448628aea8f066bbc0f37b0ecb4f11ee
Last commit: 16 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit haswell
OS X: 10.10.1-x86_64
Xcode: 6.1.1
CLT: 6.1.1.0.1.1416017670
couldn't understand kern.osversion `14.0.0'
GCC-4.2: build 5666
Clang: 6.0 build 600
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby
Run Code Online (Sandbox Code Playgroud)

即使我的Xcode(在优胜美地)命令行工具似乎是最新的(以确保我重新运行xcode-select --install)并在正确的地方

/Applications/Xcode.app/Contents/Developer 
Run Code Online (Sandbox Code Playgroud)

根据xcode-select -print-path,我(唯一)gcc

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)

并且根据的唯一问题brew doctor

Unexpected static libraries:
    /usr/local/lib/libtclstub8.6.a
    /usr/local/lib/libtkstub8.6.a
Run Code Online (Sandbox Code Playgroud)

然而,我有几个可疑的东西,特别是usr/bin/gcc-4.2,--version给了

couldn't understand kern.osversion `14.0.0'
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
...
Run Code Online (Sandbox Code Playgroud)

而且/usr/bin/i686-apple-darwin11-gcc-4.2.1,--version也给了它

couldn't understand kern.osversion `14.0.0'
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)    
...
Run Code Online (Sandbox Code Playgroud)

brew -- config报告的内容是什么

无法理解kern.osversion`14.0.0'

意思?有什么我应该做的吗?

小智 3

您不久前在这台机器上升级过 OS X 吗?我猜它们来自较旧的安装。由于gcc默认情况下未安装,因此操作系统升级可能不会删除或替换gcc其他 XCode 命令行工具。我不知道您是否真的可以安全地删除它们,但显而易见的事情是重命名它们(或将它们移动到备份子目录中),以便它们从您的PATH. 这样,自制程序就不会找到它们并使用较新的编译器(clang)。您的系统(XCode、brew)很可能会像往常一样继续,因为它们将使用clang您系统上找到的内容。

您看到的错误“无法理解 kern.osversion '14.0.0'”可能是因为它gcc是针对较旧的 OS X 内核版本编译的,而当前版本 (Yosemite/14.0.0) 是向后的与此不相容。

我不确切知道安装了哪些编译器工具,但对于有问题的gcc,您可以执行以下操作:

mv /usr/bin/gcc-4.2 /usr/bin/gcc-4.2-oldOSX10.9
Run Code Online (Sandbox Code Playgroud)

(假设这是在 10.9 上安装的;可能是在更早的版本上)。

有点不幸的是,XCode 的升级(或者更确切地说,全新版本)不会检查旧版本的命令行工具并删除它们(*)。尽管可以理解,Apple 当然假设您不使用普通 XCode 工具之外的任何东西;他们显然不会以这种方式支持自制软件。

(*) 也许确实如此,但如果您跳过一个或两个版本,它可能不会及时回溯到检查旧版本。

  • 我遇到了同样的问题。就我而言,我必须运行“brew uninstall apple-gcc42”来解决问题。 (4认同)