【问题标题】:why didn't my g++ and gcc version get upgraded?为什么我的 g++ 和 gcc 版本没有升级?
【发布时间】:2015-03-29 03:32:49
【问题描述】:

我在 Mac 上。我将我的 OSx 更新为 Yosemite。我将我的 xcode 更新到版本 6。我下载了命令行工具。

而且,每当我输入 g++ --version 时,我都会得到:

# g++ --version
couldn't understand kern.osversion `14.1.0'
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

意思是,我还在用老版本的g++和gcc。

为什么不升级?我对在 Eclipse 中使用 c++0x 很感兴趣,为此我需要一个更新的 g++/gcc 编译器。

编辑:根据下面的评论,我有两个问题:

为什么

$ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

我似乎还有旧版本的 clang?

为什么安装 xcode 和命令行工具没有创建到 clang 的正确链接?

【问题讨论】:

  • 最新的 osx/xcode 不会安装新的 gcc,它会安装新的 clang 并给它一个 gcc 别名。

标签: eclipse xcode macos c++11


【解决方案1】:

看起来您可能还安装了旧版本的 xcode。 从命令行,您可以使用

切换到正确的命令行
xcode-select --switch <path>

你应该会看到这样的东西

$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/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.1.0
Thread model: posix

$ clang --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

【讨论】:

    【解决方案2】:

    升级到 yosemite 后,我在安装 ios-deploy 时遇到了类似的问题。我也一样

    couldn't understand kern.osversion `14.1.0'
    

    对于 gcc。我最终通过以下方式解决了它:

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

    这正确地将 gcc 指向 Xcode 6.1 提供的版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      • 2011-08-16
      • 2017-07-16
      • 2010-09-15
      相关资源
      最近更新 更多